Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Go back without refreshing

I want to go back from one page(say B) to previous(say A) without refreshing it. I have a page B where if I am using it manually and I press backspace key manually it goes back to page A without refreshing, but when I am using

myElement.send_keys(Keys.BACK_SPACE)

on page B its redirecting me to page A and refreshing the page.

Note: I am using selenium for python.

like image 950
Akshay Bhasin Avatar asked Dec 07 '25 09:12

Akshay Bhasin


1 Answers

Use the webdriver's back() method:

browser.back()

Alternatively, use the history.back() through "execute script":

browser.execute_script("history.back();")
like image 144
alecxe Avatar answered Dec 09 '25 22:12

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!