New issue
Advanced search Search tips

Issue 849898 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

For WebDriver-ChromeDriver, some angular-based sites, js will been broken after find element by xpath.

Reported by k...@sophtron.com, Jun 5 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36

Steps to reproduce the problem:
1. start a chromedriver(attention here the selenium downloaded chromedriver.exe in latest release used), open https://onlinebanking.tdbank.com/#/authentication/login
2. mannually set username, password.
3. perform dev code to do 'findelement by xpath' (for example in C# we do driver.FindElement(By.XPath("/HTML[1]/BODY[1]/DIV[5]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[3]/SPAN[1]/DIV[1]/INPUT[1]")))
4. then open dev-tools in browser, view console. click login button. you will see typeerror there.
5. if all refreshed this page and do all mannual work without and find-element dev interaction, no js error will be found there, login successfully.

What is the expected behavior?
Switch to edge driver, or directly open chrome locally(not driver), everything works well without any js error.

What went wrong?
Could possibly be the find_element(also switch iframe with id) script chromedriver do will do harm to the website script. (in chromium source code that script is a minimized one in 'atom.cc', hard to read to track cause )

Did this work before? N/A 

Chrome version: 67.0.3396.62  Channel: stable
OS Version: 10.0
Flash Version: 

Can I get the original script inside 'atom.cc' for webdriver there? Need a quick fix or at least build one chromedriver locally to let it pass.
 
tdbank_error.png
514 KB View Download
Labels: Needs-Triage-M67
Components: Tests>WebDriver
Labels: Triaged-ET TE-NeedsTriageHelp
The issue seems to be related to WebDriver-ChromeDriver which seems to be out of TE-scope. Hence, adding label TE-NeedsTriageHelp for further investigation from dev team.

Thanks...!!
Cc: johnchen@chromium.org
Components: -Platform>DevTools
Status: Available (was: Unconfirmed)
I was able to repro this issue, but haven't found the root cause. There appears to be some interference between the JavaScript used by ChromeDriver to find an element, and the JavaScript used by the page itself. Finding an element should be a read-only operation, but it's possible that some of the JavaScript functions used by ChromeDriver have been re-defined to have side effects.

The original code for the JavaScript inside atom.cc is at https://github.com/SeleniumHQ/selenium/blob/381f815652933f7077762ffba5f18794ab88c9b5/javascript/chrome-driver/atoms.js#L332 . It uses some code from https://github.com/SeleniumHQ/selenium/tree/381f815652933f7077762ffba5f18794ab88c9b5/javascript/atoms/locators .

Comment 4 by k...@sophtron.com, Jun 7 2018

Thanks for pointing out the original js code, I am also trying to locate the cause, looking forward to your help in fixing.

Moreover, in 'https://www.starbucks.com/account/home' the case maybe somehow similar. Navigate to this url with chrome driver, if perform with findelement before click login button, the login button will never process successfully (if without any driver find or switchframe action, all mannually input & click login will succeed). 
But in this case there's no js exception hint in the console, notice that there's ivoation used for this login site. Could that be similar reason inside findelement js script(which may have side effects), how can I pass that though. 

Comment 5 by k...@sophtron.com, Jun 9 2018

@johnchen@chromium.org. I think I find the bug, and still need your help on how to locally update.

Bug reason:
In kCallFunctionScript [from 'https://github.com/PeterWangIntel/crosswalk-webdriver-python/blob/master/browser/js.py'], in function getPageCache (element_util.cc::FindElement -> WebViewImpl::CallFunction -> kCallFunctionScript), you use the document.cache key as '$cdc_asdjflasutopfhvcZLmcfl_' and reset it. This will both break the TDbank and Starbucks login page I mentioned above. I mean, if you change this key to another one, everything work well. So I think your people copy this key from some public lib that others can also shared this key to do their page cache? 

Then I need your help on how to locally make it work. 
As the 'kCallFunctionScript' I can only google to find it in that js.py file, but can not find in git download chromium project? how can I update this file and try locally? 

Comment 6 by k...@sophtron.com, Jun 10 2018

is it chrome/test/chromedriver/js/call_function.js will replace kCallFunctionScript ? 

Comment 7 by k...@sophtron.com, Jun 11 2018

Locally try randomly set another key will solve.
Still confused about how kCallFunctionScript been compiled from call_function.js ? 

And another question, as I use 'ninja -C out/Release chromedriver' to locally build, it turns out to be a large folder (dll, libs there, seems there should be some command to build a release version?). How can I bundle them all to only one chromedriver.exe?

Comment 8 by k...@sophtron.com, Jun 12 2018

@johnchen Any updates?

Summarize below questions.
1. any args for command 'ninja -c out/Release chromedriver' to build a release(clean) version of driver.exe (same as what we downloaded from https://chromedriver.storage.googleapis.com/index.html?path=2.40/) ?

2. how chrome/test/chromedriver/js/call_function.js get applied to 'kCallFunctionScript' in WebViewImpl::CallFunction ?

3. As locally build driver using 'ninja -C out/Release chromedriver', based on branch master or tag such as 67.XX(should be chrome version) without any code change, the builded driver.exe acts not exactly as what I downloaded (try call selenium execute script, specific sites such as ally will fail as httpcommandexcutor cannot get response from url such as /session/sessionid/excute, socket forcily closed.)
How can I get the exactly same code version(which tag or which branch should I checkout) of chromedriver.exe 2.40/2.39, and build based on that one?
 

Comment 9 by k...@sophtron.com, Jun 12 2018

@johnchen@chromium.org Looking forward to your reply on above 3 questions. Thank you.
Status: WontFix (was: Available)
Sorry for the late response. Here are the answers to questions in comment #8:
1. To build Release version of ChromeDriver on Windows, make sure you have the following lines in your args.gn:
    is_debug = false
    target_cpu = "x86"
    is_component_build = false
and then run the following command (note the uppercase -C):
    ninja -C out/Release chromedriver

2. kCallFunctionScript has the following contents, where <call_function.js> is the contents of that file.
    function() { <call_function.js>;
                         return callFunction.apply(null, arguments) }
This string constant is generated by chrome/test/chromedriver/embed_js_in_cpp.py, which is automatically called during the build.

3. To build ChromeDriver that is close to the official released version, the best thing to do is to run the official version on the command line, and note the git hash that is displayed on the screen. Then you can use git to check out the commit using that hash.

Re comment #5, the cache key was randomly chosen by us (the prefix "cdc" stands for "ChromeDriver cache"). A web site that uses the same key is likely to be intentional rather than accidental.

Sign in to add a comment