javascript - Selenium Go back without refreshing - Stack Overflow

I want to go back from one page(say B) to previous(say A) without refreshing it. I have a page B where

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.

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.

Share Improve this question edited Mar 21, 2016 at 18:02 Akshay Bhasin asked Mar 21, 2016 at 17:53 Akshay BhasinAkshay Bhasin 1652 gold badges3 silver badges11 bronze badges 4
  • That's usually a webpage behavior. Check the http headers of the original page response. If you see Cache-Control: must-revalidate, max-age=0 (or a part of this), Pragma: no-cache or Expires: date in the past (or even multiple ones of these headers), then the page will be reloaded always, since the server instructed the browser to do so. You can hack it with Fiddler or similar, but usually it's intentional (or defect - depending on the situation). – skandigraun Commented Mar 21, 2016 at 18:45
  • Its written as private. But still I understand you point and if this was true, then when I am manually pressing backspace on my keyboard its not reloading. Why is that happening? – Akshay Bhasin Commented Mar 21, 2016 at 18:50
  • Hmmm, indeed, you are right. Seems to be Selenium behavior. As a last idea from me, can you try setting the applicationCacheEnabled desiredCapability to true, and try again? (Also, trying the opposite of the answer of this question, enabling specifically all kind of caches, might worth a try) – skandigraun Commented Mar 21, 2016 at 18:58
  • doesn't help either. Any other scripting language that can help here? – Akshay Bhasin Commented Mar 21, 2016 at 19:13
Add a ment  | 

2 Answers 2

Reset to default 6

Use the webdriver's back() method:

browser.back()

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

browser.execute_script("history.back();")

Try to manage tabs, than you can route between the pages without refreshing them. Open link B in a new tab then you can go back to the first tab (link A) without refreshing

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742356819a4428602.html

相关推荐

  • javascript - Selenium Go back without refreshing - Stack Overflow

    I want to go back from one page(say B) to previous(say A) without refreshing it. I have a page B where

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信