Evaluating script fails to return value field when user prompt appears
Firefox Version
50.1.0
Platform
Linux
Steps to reproduce -
ExecuteScript("alert('test')")
Selenium log
18:07:15.023 INFO - Executing: [get: http://www.google.com])
18:07:19.294 INFO - Done: [get: http://www.google.com]
18:07:19.301 INFO - Executing: [execute script: alert('test'), []])
18:07:21.426 WARN - Exception thrown
org.openqa.selenium.WebDriverException: Failed to find value field
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'laptop', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-107-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Previously reported at https://github.com/SeleniumHQ/selenium/issues/3187 and https://github.com/mozilla/geckodriver/issues/336#issuecomment-263306804
The Execute Script command likely fails to return because the injected script raises an alert.
I can confirm that I am also seeing this issue using Firefox 53.0.3 (64 bit), Selenium 3.4.0 (Java), Geckdriver 0.16 and on Mac OSX
Steps to reproduce
((JavascriptExecutor) driver).executeScript("alert('Test')");
Log
org.openqa.selenium.WebDriverException: Failed to find value field
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'Dev-Mac-Mini.local', ip: '10.10.17.20', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=/var/folders/x2/m5fy4hhd5rn2h9hxd4h1qlhm0000gn/T/rust_mozprofile.Zcrm2hxdf1Ql, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0.3, platformVersion=16.3.0, moz:processID=52382.0, browserName=firefox, javascriptEnabled=true, platformName=darwin}]
@wfloutier I have a suspicion that error is fixed in a more recent Firefox version. Why did you not run it with Firefox Nightly before reporting it? Firefox 53 is fairly old.
@andreastt You're right, I should have checked first. I have now so and I'm still seeing the issue with the latest Firefox nightly build (55a). Worth mentioning incase others thought the issue was fixed.
org.openqa.selenium.WebDriverException: Failed to find value field
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'Dev-Mac-Mini.local', ip: '10.10.17.20', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=/var/folders/x2/m5fy4hhd5rn2h9hxd4h1qlhm0000gn/T/rust_mozprofile.vRF8qhl6d5PN, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=55.0a1, platformVersion=16.3.0, moz:processID=66587.0, browserName=firefox, javascriptEnabled=true, platformName=darwin}]
Session ID: 718b8a86-196a-b348-9ec3-c3872e0ca3dd
@wfloutier Can you include a trace-level log for your run?
So I checked with Marionette and it works. So a simple test via Selenium brought up the following failure:
1496759218236 geckodriver::marionette TRACE -> 120:[0,2,"executeScript",{"args":[],"newSandbox":false,"script":"alert('Test')","scriptTimeout":null,"specialPowers":false}]
1496759218239 Marionette TRACE 0 -> [0,2,"executeScript",{"args":[],"newSandbox":false,"script":"alert('Test')","scriptTimeout":null,"specialPowers":false}]
1496759218272 Marionette TRACE 0 <- [1,2,null,{}]
1496759218293 geckodriver::marionette TRACE <- [1,2,null,{}]
2017-06-06 16:26:58.466 plugin-container[6180:17325061] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0xa43f, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2017-06-06 16:26:58.467 plugin-container[6180:17325061] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0xa803, name = 'com.apple.CFPasteboardClient'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1496759218514 webdriver::server DEBUG ← 500 Internal Server Error {"value":{"error":"unknown error","message":"Failed to find value field","stacktrace":"stack backtrace:\n 0: 0x10af531c4 - backtrace::backtrace::trace<closure>\n at /Volumes/data/Users/henrik/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.2/src/backtrace/mod.rs:42\n 1: 0x10af5358f - backtrace::capture::Backtrace::new::hbc1a12654c8fdba8\n at /Volumes/data/Users/henrik/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.2/src/capture.rs:64\n 2: 0x10ae7c49a - webdriver::error::{{impl}}::new<&str>\n at /Volumes/data/Users/henrik/.cargo/registry/src/github.com-1ecc6299db9ec823/webdriver-0.25.2/src/error.rs:232\n 3: 0x10ae887c7 - geckodriver::marionette::{{impl}}::response\n at src/marionette.rs:653\n 4: 0x10ae959bf - geckodriver::marionette::{{impl}}::send_command\n at src/marionette.rs:1381\n 5: 0x10ae86f5c - geckodriver::marionette::{{impl}}::handle_command\n at src/marionette.rs:528\n 6: 0x10ae29398 - webdriver::server::{{impl}}::run<geckodriver::marionette::MarionetteHandler,geckodriver::marionette::GeckoExtensionRoute>\n at /Volumes/data/Users/henrik/.cargo/registry/src/github.com-1ecc6299db9ec823/webdriver-0.25.2/src/server.rs:65\n 7: 0x10ae7d28a - webdriver::server::start::{{closure}}<geckodriver::marionette::MarionetteHandler,geckodriver::marionette::GeckoExtensionRoute>\n at /Volumes/data/Users/henrik/.cargo/registry/src/github.com-1ecc6299db9ec823/webdriver-0.25.2/src/server.rs:258\n 8: 0x10ada6f5a - std::sys_common::backtrace::__rust_begin_short_backtrace<closure,()>\n at /Users/travis/build/rust-lang/rust/src/libstd/sys_common/backtrace.rs:136\n 9: 0x10adb5643 - std::thread::{{impl}}::spawn::{{closure}}::{{closure}}<closure,()>\n at /Users/travis/build/rust-lang/rust/src/libstd/thread/mod.rs:336\n 10: 0x10ae7151a - std::panic::{{impl}}::call_once<(),closure>\n at /Users/travis/build/rust-lang/rust/src/libstd/panic.rs:296\n 11: 0x10adb6219 - std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()>\n at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:454\n 12: 0x10b40d57a - __rust_maybe_catch_panic\n at src/libpanic_unwind/lib.rs:98\n 13: 0x10adb5b4c - std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>\n at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:433\n 14: 0x10adb3075 - std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()>\n at /Users/travis/build/rust-lang/rust/src/libstd/panic.rs:361\n 15: 0x10adb50ab - std::thread::{{impl}}::spawn::{{closure}}<closure,()>\n at /Users/travis/build/rust-lang/rust/src/libstd/thread/mod.rs:335\n 16: 0x10ae11eb3 - alloc::boxed::{{impl}}::call_box<(),closure>\n at /Users/travis/build/rust-lang/rust/src/liballoc/boxed.rs:648\n 17: 0x10b409765 - std::sys::imp::thread::{{impl}}::new::thread_start\n at src/libstd/sys_common/thread.rs:21\n 18: 0x7fff9c97393a - _pthread_body\n 19: 0x7fff9c973886 - _pthread_start"}}
The problem here is that geckodriver or webdriver expacts a value field returned by the command, which is not given in this case due to an early abort of the command:
https://dxr.mozilla.org/mozilla-central/source/testing/marionette/proxy.js#127-130
So we could add fake properties to the returned data in proxy.js but not sure if that is really what we want. @andreastt what would you suggest?
So we could add fake properties to the returned data in proxy.js but not sure if that is really what we want.
That doesn’t scale because other commands might expect different return values, but I’ll look into this. We have a couple of options.
I assume that this issue is not only related to execute_script but to any command which usually returns a non-empty dict.
Also sprach Henrik Skupin:
I assume that this issue is not only related to
execute_scriptbut to any command which usually returns a non-empty dict.
Right, and there’s no way to generalise that.
If the evaluate script functions that are run in the content frame script could intercept and resolve with a null value when an alert appeared, we would be in a much better position. But I don’t think this is possible because the alert blocks the content frame JS thread in addition to the document JS thread.
I think the only way to circumvent this is by checking the return value from the proxied call to evaluate in the frame script and set resp.body.value to null if the return value is undefined.
I fixed this in https://bugzilla.mozilla.org/show_bug.cgi?id=1370850.
hi @andreastt does latest release v0.18.0 contain your fix?
The change here was in Marionette which is part of Firefox. And it should work for you know given that Firefox 55.0 has been released earlier this week.
I see, and that makes sense.
We are using Selenium + Geckodriver + Firefox for UI tests, and everything is installed and run on AWS Linux. But on AWS Linux, we could only install Firefox ESR, and the latest version is 52.3.0, https://www.mozilla.org/en-US/firefox/52.3.0/releasenotes/
Do you know when this fix will go into Firefox ESR?
Thanks!
The fix will not be part of any 52.x0 ESR release. So whether you have your script downloading a more recent version of Firefox and not rely on the system's package manager, or you have to wait until the next major version bump of ESR will happen. But this will be Firefox 59 and will still take a while.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.