Home > Software design >  Is it possible to click the back button in the browser using Playwright?
Is it possible to click the back button in the browser using Playwright?

Time:11-04

In a browser there's often arrow buttons that go forward and backward in history:

enter image description here

Can these buttons be clicked on via playwright?

There's no elements for them so I was wondering if this is possible...

await navigationObject(page).backButton.click();

CodePudding user response:

await page.goBack()

Or

await page.goForward()

You can find more info here: https://playwright.dev/docs/api/class-page#page-go-back

CodePudding user response:

Try the History API:

window.history.back()

and

window.history.forward()

See: https://developer.mozilla.org/en-US/docs/Web/API/History_API

  • Related