ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

goback failure #1065

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Issue Description:
Problem involves using Selenium Python bindings to automate web page. Execution 
of following line fails to return to previous page, but rather goes back to 
earlier page:

        driver.back()

Steps to reproduce:

(Page returns a table containing protected health information, and cannot be 
shared under HIPAA guidelines.)

Log shows that multiple pages in history returned by Page.getNavigationHistory 
share same id.  I suspect that lack of unique id causes problem.  There is no 
problem if a breakpoint is inserted at driver.back() and the back button in the 
browser is clicked manually.

Log file for GoBack Command/Response

[22.764][INFO]: COMMAND GoBack {
   "sessionId": "xxxxxxxxxxxxxxxxxxxxxxxxxx"
}
[22.764][INFO]: Waiting for pending navigations...
[22.764][INFO]: Done waiting for pending navigations
[22.764][DEBUG]: DEVTOOLS COMMAND Page.getNavigationHistory (id=234) {

}
[22.766][DEBUG]: DEVTOOLS RESPONSE Page.getNavigationHistory (id=234) {
   "currentIndex": 6,
   "entries": [ {
      "id": 1,
      "title": "",
      "url": "data:,"
   }, {
      "id": 3,
      "title": "Login for TEDDY & PANDA Staff",
      "url": "https://www.pandastudy.org/home/login_page.aspx"
   }, {
      "id": 4,
      "title": "Login to PANDA / TEDDY Study",
      "url": "https://www.pandastudy.org/member/account/switch_study_page.aspx"
   }, {
      "id": 5,
      "title": "Member Main Page",
      "url": "https://www.pandastudy.org/member/member_main_page.aspx?Study=TEDDY"
   }, {
      "id": 6,
      "title": "TEDDY :: Subject Accelerometer Management",
      "url": "https://www.pandastudy.org/core/secure/accelerometers/manager.aspx"
   }, {
      "id": 6,
      "title": "TEDDY :: Subject Accelerometer Management",
      "url": "https://www.pandastudy.org/core/secure/accelerometers/manager.aspx"
   }, {
      "id": 6,
      "title": "TEDDY :: Subject Accelerometer Management",
      "url": "https://www.pandastudy.org/core/secure/accelerometers/manager.aspx"
   } ]
}
[22.766][DEBUG]: DEVTOOLS COMMAND Page.navigateToHistoryEntry (id=235) {
   "entryId": 6
}
[22.778][DEBUG]: DEVTOOLS RESPONSE Page.navigateToHistoryEntry (id=235) {

}
[22.778][INFO]: Waiting for pending navigations...
[22.778][INFO]: Done waiting for pending navigations
[22.778][INFO]: RESPONSE GoBack

Original issue reported on code.google.com by rdst...@steeds.us on 25 Mar 2015 at 6:45

GoogleCodeExporter commented 9 years ago
We tried it on gmail thinking that problem was due to an ajax page which had a 
back button override. But it does not reproduce

Can you please provide a testcase & the pages ? 
This would help us to reproduce the issue
You can have all the confidential informed stripped out.

Original comment by gmanikp...@chromium.org on 26 Mar 2015 at 6:23

GoogleCodeExporter commented 9 years ago
I'm sorry, but I cannot provide a test case and the pages.  For you to 
reproduce the issue you would have to have an active sessionid that would give 
you access to confidential information.

I have done some further digging into the problem, and found:

1.  There is nothing wrong with chromedriver.  It (reasonably) implements 
driver.back() by using the Page.getNavigationHistory and 
Page.navigateToHistoryEntry to go back one page.

2.  The problem is that the "entries" array returned by 
Page.getNavigationHistory, the "id" is not unique each entry.

3.  Page.navigateToHistoryEntry relies on the id being unique, and returns the 
first page in the list with that id.

4.  In the log I submitted, the last 3 pages shared the same supposedly unique 
"id":6, and Page.navigateToHistoryEntry navigated to the first instance which 
was actually two pages back.

I can tell you that this web page contains a search form in an iframe which is 
dynamically reloaded after each search.  Each time the iframe is reloaded, a 
new entry is added to the entries array returned by 
Page.navigateToHistoryEntry, but the id for that entry remains the same as the 
previous entry.

I now see that the underlying problem is that 
//src/content/browser/frame_host/navigation_entry_impl.cc is not generating 
unique id's when this site is browsed.

Should this issue be closed and referred to another project?

Original comment by rdst...@steeds.us on 27 Mar 2015 at 5:08

GoogleCodeExporter commented 9 years ago
I am closing this defect, Please log a new issue in chromium project 
https://code.google.com/p/chromium/issues/list

Also, I understand you cannot share the test data due to its confidentiality. 
But it would be helpful if you could provide some sample test case & page with 
the team.

Thanks,

Original comment by gmanikp...@chromium.org on 27 Mar 2015 at 10:41

GoogleCodeExporter commented 9 years ago
I think my analysis in comment#2 is wrong.

Further digging through the code suggests that chromedriver is actually 
implementing the goback() command by executing the javascript 
window.history.back() in line 216 of web_view_impl.cc .

I believe that window.history.back() should work, but there do seem to be 
multiple unresolved issues with it in chromium.

As a workaround in my python code, I have replaced the line in my code:
  driver.back()
with the new line:     
  driver.find_element_by_tag_name('body').send_keys('\b')

This sends a backspace keystroke to the browser which is a keyboard shortcut 
for the browser back button in chrome.

Since making this change, my python webdriver program has performed as expected.

Original comment by rdst...@steeds.us on 31 Mar 2015 at 11:39