Code Monkey home page Code Monkey logo

geckodriver's Introduction

geckodriver

Proxy for using W3C WebDriver compatible clients to interact with Gecko-based browsers.

This program provides the HTTP API described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox. It translates calls into the Marionette remote protocol by acting as a proxy between the local- and remote ends.

Installation

Geckodriver can be installed through various distribution channels:

  • You can download pre-built binaries for the most common platforms from our Releases page on GitHub.
  • Alternatively, you can compile it yourself by using:
    • cargo install geckodriver, or
    • Checking out the release branch or a specific tag.

For a detailed list of changes included in each release, please refer to the change log.

Documentation

Source code

geckodriver is made available under the Mozilla Public License.

Its source code can be found in mozilla-central under testing/geckodriver. This GitHub repository is only used for issue tracking and making releases.

Custom release builds

If a binary is not available for your platform, it's possibe to create a custom build using the Rust toolchain. To do this, checkout the release tag for the version of interest and run cargo build. Alternatively the latest version may be built and installed from crates.io using cargo install geckodriver.

Contact

The mailing list for geckodriver discussion is https://groups.google.com/a/mozilla.org/g/dev-webdriver.

There is also a Matrix channel on chat.mozilla.org to talk about using and developing geckodriver in #webdriver.

geckodriver's People

Contributors

andreastt avatar automatedtester avatar codytubbs avatar drmarcii avatar jgraham avatar joshbruning avatar juangj avatar kirhgoph avatar martiansideofthemoon avatar minusnine avatar mjzffr avatar mozilla-github-standards avatar mythsunwind avatar nikolas avatar ondram avatar thc202 avatar vladikoff avatar whimboo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geckodriver's Issues

Use Travis to make releases

If we cross compile using travis, then we can also use the GH API to check if there is a new release tag associated with the current push, but no corresponding release and, if so, get it to upload the builds as the new release.

sendKeys should append text to existing value (not prepend)

Let there be a text input with non-empty the value and we type into it:

1441556205590   Marionette  DEBUG   conn0 -> ({"name":"sendKeysToElement","parameters":{"id":"d7875fb3-32d5-45ed-8dea-580d72865f19","value":["."," ","S","o","m","e"," ","t","e","x","t"]},"sessionId":"ae123b3d-c5ab-4733-833d-1e08319f82f4","to":"0"})
1441556205604 Marionette: Element does not have an accessible object1441556205627   Marionette  DEBUG   conn0 client <- ({"from":"0","ok":true})
ERROR:webdriver::server: Returning status Ok
ERROR:webdriver::server: Returning body {}
сен 06, 2015 8:16:45 PM org.openqa.selenium.remote.RemoteWebDriver log
INFO: Executed: [ae123b3d-c5ab-4733-833d-1e08319f82f4, sendKeysToElement {id=d7875fb3-32d5-45ed-8dea-580d72865f19, value=[Ljava.lang.CharSequence;@3a1f26c4}]
сен 06, 2015 8:16:45 PM org.openqa.selenium.remote.RemoteWebDriver log
INFO: Executing: getElementAttribute [ae123b3d-c5ab-4733-833d-1e08319f82f4, getElementAttribute {id=d7875fb3-32d5-45ed-8dea-580d72865f19, name=value}]
1441556205633   Marionette  DEBUG   conn0 -> ({"name":"getElementAttribute","parameters":{"id":"d7875fb3-32d5-45ed-8dea-580d72865f19","name":"value"},"sessionId":"ae123b3d-c5ab-4733-833d-1e08319f82f4","to":"0"})
1441556205635   Marionette  DEBUG   conn0 client <- ({"from":"0","value":". Some textExample text","status":"success","sessionId":"ae123b3d-c5ab-4733-833d-1e08319f82f4"})
ERROR:webdriver::server: Returning status Ok
ERROR:webdriver::server: Returning body {"value":". Some textExample text"} 

Expected: "Example text. Some text"

no stdio handle error

@AutomatedTester, I'm not sure if this is a wires issue, a Marionette issue or a Ruby ChildProcess issue. It is only a problem on Windows; Linux & Mac work fine.

-> POST session
   >>> http://127.0.0.1:4444/session | {"desiredCapabilities":{"browserName":"firefox","browserVersion":null,"platformName":null,"platformVersion":"any","acceptSslCerts":false,"takesScreenshot":false,"takesElementScreenshot":false,"pageLoadStrategy":"normal","marionette":true}}
<- {"error":"unknown error","message":"no stdio handle available for this process"}

I'm not sure why, but I don't get this error if I set @process.io.inherit! on the ChildProcess instance that executes wires. While this works, it also fills stdout with all of the marionette debug information, so if I can figure out a better way to solve this, that would be great.

@p0deje - I'm not very familiar with I/O or ChildProcess class; the server_command array sent to ChildProcess#build is:
["C:\drivers/wires.exe", "--binary=c:\firefoxes\beta\App\Firefox\firefox.exe", "--webdriver-port=4444"]
Do you have any idea what the issue might be, or should I see if Jari has insight?

Missing "no such alert" error

This alert is closed when attempting to call text on it

-> GET session/7510bd48-3dfe-4851-828b-728565b330b6/alert/text
1452047166834   Marionette  DEBUG   conn0 -> Command {id: 7, name: "getTextFromDialog", parameters: {}}
1452047166835   Marionette  DEBUG   conn0 <- Response {id: 7, error: {"error":"no such alert","message":"No tab modal was open when attempting to get the dialog text","stacktrace":null}, body: null}
<- {"error":"unknown error","message":"Error value has no status"}

wires fails to handle ActionChain with Keys

Attempting to perform an ActionChain containing keys fails in wires 0.6.2 on OS X. It's possible this doesn't work on other platforms and revisions. I am testing against selenium 2.49.2.

Reduced test:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Applications/FirefoxNightly.app/Contents/MacOS/firefox'
driver = webdriver.Firefox(capabilities=firefox_capabilities)

driver.get('data:text/html,<a href="https://mozilla.org">Click This!</a>')
tag = driver.find_element_by_tag_name("a")

# Simulate ctrl-shift clicking the anchor tag.
action = ActionChains(driver)
ctrl_key = Keys.COMMAND # mac
#ctrl_key = Keys.CONTROL # not mac
action.key_down(ctrl_key).key_down(Keys.SHIFT).click(tag).key_up(Keys.SHIFT).key_up(ctrl_key).perform()

Resulting error:

Traceback (most recent call last):
  File "keys_bug.py", line 18, in <module>
    action.key_down(ctrl_key).key_down(Keys.SHIFT).click(tag).key_up(Keys.SHIFT).key_up(ctrl_key).perform()
  File "/Users/ericrahm/dev/comp/venv/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py", line 72, in perform
    action()
  File "/Users/ericrahm/dev/comp/venv/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py", line 172, in <lambda>
    "value": self._keys_to_typing(value) }))
  File "/Users/ericrahm/dev/comp/venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "/Users/ericrahm/dev/comp/venv/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 188, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: POST /session/c538f756-c6d7-fc45-a3d8-bfe0803c71a8/keys did not match a known command

Question: Supporting stable Firefox

Could you please elaborate on the plan for the releases of Geckodriver? When I read the issues and the releases it says either that "Only Nightly, DevEdition and Beta are officially supported" or that you should use Firefox nightly. But since the release of Firefox 47 you need to drive it with Marionette/Gecko so if I'm running Selenium and want to use Firefox 47 that is not supported? Meaning users should stay on 46 until Geckodriver 1.0? Or what's the big picture/plan?

v0.7.1 and windows

Is there a windows version of v0.7.1 ? I see there was for 0.6.2. Was it just missed?

It is not possible to set a prompt value

INFO: Executing: setAlertValue [2c70c183-25a1-49e2-aeb5-0a6b0275939d, setAlertValue {text=cheese}]
ERROR:webdriver::server: Returning status BadRequest
ERROR:webdriver::server: Returning body {"message":"Missing 'handle' parameter","status":"invalid argument"}

Marionette Error: Error: Permission denied to access property [name]

STR

Load up the proxy and run the test project below:

git clone https://github.com/vladikoff/intern-quick-test.git -b m-reload
cd intern-quick-test 
npm i
npm test

(You can target custom firefox builds using this command example:

npm test firefoxBinary=/<path>/gecko-dev/obj-x86_64-apple-darwin14.4.0/dist/Nightly.app/Contents/MacOS/firefox-bin

)

Actual

{"script":"location.reload();","args":[]}] Marionette Error: Error: Permission denied to access property "reload"

Full log:

× firefox on any platform - suite1 - testTrue (2.014s)
JavaScriptError: [POST http://localhost:4444/session/71f8589c-6dc0-8c44-bf54-2a8e144e8686/execute / {"script":"location.reload();","args":[]}] Marionette Error: Error: Permission denied to access property "reload"
  at ProxiedSession._post  <node_modules/intern/node_modules/leadfoot/Session.js:59:30>
  at ProxiedSession.Session.execute  <node_modules/intern/node_modules/leadfoot/Session.js:583:15>
  at Command.<anonymous>  <node_modules/intern/node_modules/leadfoot/Command.js:635:19>
  at <node_modules/intern/node_modules/dojo/Promise.ts:393:15>
  at Object.run [as _onImmediate]  <node_modules/intern/node_modules/dojo/Promise.ts:237:7>
  at processImmediate [as _immediateCallback]  <timers.js:354:15>
  at Command.target.(anonymous function) [as execute]  <node_modules/intern/node_modules/leadfoot/Command.js:610:11>
  at Test.registerSuite.testTrue [as test]  <testfunc1.js:12:10>
  at start.then.finally.self.timeElapsed  <node_modules/intern/lib/Test.js:211:24>
  at <node_modules/intern/node_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/intern/node_modules/dojo/Promise.ts:11:11>
  at <node_modules/intern/node_modules/dojo/Promise.ts:317:4>
  at Object.run [as _onImmediate]  <node_modules/intern/node_modules/dojo/Promise.ts:237:7>
  at processImmediate [as _immediateCallback]  <timers.js:354:15>

Expected

.execute should reload the page.

Test Code

 testTrue: function () {
      return this.remote // get remote browser
        .get(require.toUrl('http://mozilla.org')) // load a page into the browser
        .execute('location.reload();'); // use selenium execute to reload the page.
    }

( P.S. I know there is a Selenium refresh command but this error happens with any .execute command accessing window objects )

Cannot get rid of "first run" page

I've been using selenium + Firefox webdriver to test my web app, but Firefox 47 broke selenium integration again, and the proposed resolution was to switch to geckodriver instead. However after doing so, I can no longer get rid of the "first run" page. What makes matters even worse is that this "first run" page opens in a separate window that doesn't close then the selenium webdriver shuts down.

This is how I try to disable it:

profile = webdriver.FirefoxProfile()
profile.set_preference(
    'browser.startup.homepage_override.mstone',
    'ignore'
)
profile.set_preference(
    'browser.startup.homepage',
    'about:blank'
)
profile.set_preference(
    'startup.homepage_welcome_url',
    'about:blank'
)
profile.set_preference(
    'startup.homepage_welcome_url.additional',
    'about:blank'
)
profile.set_preference(
    'intl.accept_languages',
    'en'
)
capabilities = webdriver.DesiredCapabilities.FIREFOX
capabilities['marionette'] = True
driver = Firefox(firefox_profile=profile, capabilities=capabilities)

How can I get rid of that damn page with geckodriver?

--webdriver-port does not change the port number

when running wires /Users/dburns/development/mozilla/mozilla-inbound/obj-ff-dbg/dist/Nightly.app/Contents/MacOS/firefox --webdriver-port=60896 wires still starts up on port 4444 instead of the one I gave it.

Expected payload for adding cookie does not match spec

When adding a cookie, sending a payload to POST /session/:sessionid/cookie of

{ 
  "cookie":
  {
    "name": "cookieName",
    "value": "cookieValue"
  }
}

results in a response of

{
  "error":"invalid argument",
  "message":"Missing 'name' parameter"
}

Apparently, wires is expecting the cookie to not be wrapped in an outer object. This does not match the spec, which in step 3 of the algorithm for the addCookie command states "Let cookie be the result of getting a property named 'cookie' from the parameters argument."

async_script doesn't work?

Hey,
really excited about the new driver! We run the project Browsertime and we use the NodeJS version of Selenium and we started to move to the Geckodriver since we need to with Firefox 47 but there's one thing that stops us and that is that it doesn't seems to work with running async scripts (in the Selenium world driver. executeAsyncScript). When I tried I get:

POST /session/21c00e28-7c85-274f-a797-85f566f13ac9/timeouts/async_script did not match a known command

And we use that to get the HAR file from the HAR-export-trigger when we test the performance of a page. I use geckodriver-0.8.0-OSX.

Thanks
Peter

Support Firefox with e10s enabled

In order to make progress on testing e10s-enabled Firefox I added some prefs to marionette.js. After launching the browser I was unable to interact with it, which is a bit surprising as marionette itself does support e10s.

Enable e10s patch:

diff --git a/src/marionette.rs b/src/marionette.rs
index 66da6c1..bbc3f65 100644
--- a/src/marionette.rs
+++ b/src/marionette.rs
@@ -151,7 +151,7 @@ impl ToMarionette for GeckoContextParameters {
     }
 }

-pub static FIREFOX_PREFERENCES: [(&'static str, PrefValue); 50] = [
+pub static FIREFOX_PREFERENCES: [(&'static str, PrefValue); 55] = [
     ("app.update.auto", PrefValue::PrefBool(false)),
     ("app.update.enabled", PrefValue::PrefBool(false)),
     ("browser.displayedE10SPrompt.1", PrefValue::PrefInt(5)),
@@ -169,8 +169,13 @@ pub static FIREFOX_PREFERENCES: [(&'static str, PrefValue); 50] = [
     ("browser.sessionstore.resume_from_crash", PrefValue::PrefBool(false)),
     ("browser.shell.checkDefaultBrowser", PrefValue::PrefBool(false)),
     ("browser.startup.page", PrefValue::PrefInt(0)),
-    ("browser.tabs.remote.autostart.1", PrefValue::PrefBool(false)),
-    ("browser.tabs.remote.autostart.2", PrefValue::PrefBool(false)),
+    ("browser.tabs.remote.autostart.1", PrefValue::PrefBool(true)),
+    ("browser.tabs.remote.autostart.2", PrefValue::PrefBool(true)),
+    ("browser.tabs.remote.autostart.3", PrefValue::PrefBool(true)),
+    ("browser.tabs.remote.autostart.4", PrefValue::PrefBool(true)),
+    ("browser.tabs.remote.autostart.5", PrefValue::PrefBool(true)),
+    ("browser.tabs.remote.autostart.6", PrefValue::PrefBool(true)),
+    ("dom.ipc.processCount", PrefValue::PrefInt(1)),
     ("browser.tabs.warnOnClose", PrefValue::PrefBool(false)),
     ("browser.tabs.warnOnOpen", PrefValue::PrefBool(false)),
     ("browser.warnOnQuit", PrefValue::PrefBool(false)),

Reduced test:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Applications/FirefoxNightly.app/Contents/MacOS/firefox'
driver = webdriver.Firefox(capabilities=firefox_capabilities)
# Load a dummy page
driver.get('data:text/html,Hello World!')
# Try to open a tab
self.driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + "t")

Use Travis to cross-compile

It should be possible, with a little effort, to get Travis cross-compiling wptrunner for other platforms. This is a prerequisite for making releases using wptrunner.

Failed to decode request body as json

STR

Get Wires, I used master with 4078409
Start wires with

./wires -b /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin
git clone https://github.com/vladikoff/intern-quick-test.git -b fxa-signup
cd intern-quick-test 
npm i
npm test

Expected

Fill out the form on accounts.firefox.com and submit

Actual

➜  intern-quick-test git:(fxa-signup) ✗ npm test

> [email protected] test /Users/vladikoff/dev/intern-quick-test
> intern-runner config=intern.js

Listening on 0.0.0.0:10232
Tunnel started
‣ Created session firefox on any platform (fde7e7a7-ccde-fd46-9c84-2c93c18991bc)
× firefox on any platform - suite1 - testTrue (1.524s)
UnknownError: [POST http://localhost:4444/session/fde7e7a7-ccde-fd46-9c84-2c93c18991bc/element/%5Bobject%20Object%5D/click] Failed to decode request body as json: 
  at ProxiedSession._post  <node_modules/intern/node_modules/leadfoot/Session.js:59:30>
  at Element._post  <node_modules/intern/node_modules/leadfoot/Element.js:23:31>
  at Element.click  <node_modules/intern/node_modules/leadfoot/Element.js:138:15>
  at Command.<anonymous>  <node_modules/intern/node_modules/leadfoot/Command.js:680:19>
  at <node_modules/intern/node_modules/dojo/Promise.ts:393:15>
  at run  <node_modules/intern/node_modules/dojo/Promise.ts:237:7>
  at <node_modules/intern/node_modules/dojo/nextTick.ts:44:3>
  at doNTCallback0  <node.js:419:9>
  at process._tickCallback  <node.js:348:13>
  at Command.target.(anonymous function) [as click]  <node_modules/intern/node_modules/leadfoot/Command.js:674:11>
  at Test.registerSuite.testTrue [as test]  <testfunc1.js:15:12>
  at <node_modules/intern/lib/Test.js:211:24>
  at <node_modules/intern/node_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/intern/node_modules/dojo/Promise.ts:11:11>
  at <node_modules/intern/node_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/intern/node_modules/dojo/Promise.ts:237:7>
  at <node_modules/intern/node_modules/dojo/nextTick.ts:44:3>
  at doNTCallback0  <node.js:419:9>
  at process._tickCallback  <node.js:348:13>

Could be related to #10

Unable to start two sessions in sequence

I've been trying to add Marionette support to the Selenium Docker images in SeleniumHQ/docker-selenium#189 and have encountered an issue where after an initial session is created and deleted, any subsequent attempts to start a session fail. The initial wires process is successfully terminated, but each following failure to start a session orphans the wires process.

I found this StackOverflow question, which concludes that randomizing the Marionette port solves the issue. This suggests that perhaps the port is not being properly released?

WebDriverException: Unsupported marionette protocol version 2, required 3

When trying to use the MarrionetteDriver for the first time I got this exception:

org.openqa.selenium.WebDriverException: Unsupported marionette protocol version 2, required 3 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.84 seconds
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'XXXXXX', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.firefox.MarionetteDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:234)
at org.openqa.selenium.firefox.MarionetteDriver.run(MarionetteDriver.java:79)
at org.openqa.selenium.firefox.MarionetteDriver.(MarionetteDriver.java:73)
at org.openqa.selenium.firefox.MarionetteDriver.(MarionetteDriver.java:45)
at com.passwordsage.LoginTest.openBrowser(LoginTest.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

POST /session does not specify "application/json" in the response

STR

Send a POST request to localhost:4444/session
with JSON payload of

{"desiredCapabilities":{"browserName":"firefox","name":"intern.js","idle-timeout":60}}

Expected

A Content-Type of "application/json" should be set in the response

Actual


image

More Info

I'm not sure if this is in the spec or not, but if you are returning JSON then it is good to the content type.
Selenium does this

Cannot access global JS variables when executing script

JS executed via the /session/{sessionid}/execute/sync url appears to operate on a "window" object that is distinct from the actual "window" object that JS inside the page operates on. E.g. assume the following snippet in the html page:

    <script type="text/javascript">
      window.onload = function() {
        window.foobar = "hi";
      };
    </script>

Then the request curl -d '{"script":"return window.foobar;", "args":[]}' 'http://localhost:2002/session/<sessionid>/execute/sync' returns {"value":null}.

Interestingly enough values can be set and then retrieved, though they don't affect (i.e. are not visible to) the JS in the page:

$ curl -d '{"script":"window.foobar = \\"bye\\";", "args":[]}' 'http://localhost:2002/session/<sessionid>/execute/sync'
{"value":null}
$ curl -d '{"script":"return window.foobar;", "args":[]}' 'http://localhost:2002/session/<sessionid>/execute/sync'
{"value":"bye"}

Obviously this works fine using the FirefoxDriver, ChromeDriver, etc.

active element

This is with Firefox 45, Wires 0.6.2

-> GET session/0a0be41a-490e-7a42-b5e9-48f4589ed26b/element/active
1457560012250   Marionette  TRACE   conn0 -> [0,3,"getActiveElement",{}]
1457560012252   Marionette  TRACE   conn0 <- [1,3,null,{"value":"e4c34c1e-7982-7f4c-ba24-0b9f74bf78a7"}]
<- {"error":"unknown error","message":"Failed to convert data to an object"}

POST /session sessionId response has extra `{ }` in the response

STR

  1. POST /session with
{"desiredCapabilities":{"browserName":"firefox","name":"intern.js","idle-timeout":60}}

Actual

wires response

{
  "sessionId": "{e55fd540-babf-3548-86e8-2e20b8fb3bb1}",
  "value": {
    "XULappId": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
    "acceptSslCerts": false,
    "appBuildId": "20150819030206",
    "browserName": "Firefox",
    "browserVersion": "43.0a1",
    "device": "desktop",
    "platform": "DARWIN",
    "platformName": "DARWIN",
    "platformVersion": "43.0a1",
    "proxy": {},
    "raisesAccessibilityExceptions": false,
    "rotatable": false,
    "takesElementScreenshot": true,
    "takesScreenshot": true,
    "version": "43.0a1"
  }
}

Expected

Expected to have sessionId to be a valid uuid.v4 ( https://en.wikipedia.org/wiki/Universally_unique_identifier ) without { }

Selenium response

{
  "sessionId": "b510d3dd-5939-4b0e-a523-1a1a90498b0d",
  "status": 0,
  "state": null,
  "value": {
    "platform": "MAC",
    "javascriptEnabled": true,
    "acceptSslCerts": true,
    "browserName": "firefox",
    "rotatable": false,
    "locationContextEnabled": true,
    "webdriver.remote.sessionid": "b510d3dd-5939-4b0e-a523-1a1a90498b0d",
    "version": "40.0",
    "databaseEnabled": true,
    "cssSelectorsEnabled": true,
    "handlesAlerts": true,
    "webStorageEnabled": true,
    "nativeEvents": false,
    "applicationCacheEnabled": true,
    "takesScreenshot": true
  },
  "class": "org.openqa.selenium.remote.Response",
  "hCode": 1424204968
}

local path overrides and unreleased versions

Naively checking out just wires and running cargo build --no-default-features, I was getting an error about an unresolved import:

src\marionette.rs:22:43: 22:56 error: unresolved import `webdriver::command::WebDriverCommand::GetPageSource`. There is no `GetPageSource` in `webdriver::command::WebDriverCommand` [E0432]
src\marionette.rs:22     GoBack, GoForward, Refresh, GetTitle, GetPageSource, GetWindowHandle,
                                                               ^~~~~~~~~~~~~

If I understand correctly, to compile the latest wires I actually need to use @AutomatedTester's branch adding GetPageSource (mozilla/webdriver-rust#20) rather than the latest version 0.5.0 of webdriver on Cargo.

I was able to fix the build by adding a .cargo\config file as described here to point to my clone of the webdriver-rust repo along side wires:

paths = ["./webdriver-rust"]

That was no problem, but might be worth mentioning in the README. 😺

Firefox Nightly crashes with latest changes to marionette webdriver

I'm on changeset: 286985:a75d87f4cf52. cc @AutomatedTester @jgraham

With this sample file below (or JavaScript launcher):

import os
import unittest
import random
import time
import sys

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium import webdriver


from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX
# Disable for now, https://github.com/jgraham/wires/issues/46
if "FIREFOX_BIN" in os.environ:
    print "Loading custom build..."
    firefox_capabilities['marionette'] = True
    firefox_capabilities['binary'] = os.environ["FIREFOX_BIN"]
    #firefox_capabilities['loggingPrefs'] = {'browser': 'ALL'}
    binary = FirefoxBinary(os.environ["FIREFOX_BIN"])

from selenium import webdriver

class FxaTests(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox(capabilities=firefox_capabilities, firefox_binary=binary)
        self.driver.implicitly_wait(20)  # seconds

    def test_fxa_signup(self):
        time.sleep(200000)
        time.sleep(200000)
        time.sleep(200000)
        time.sleep(200000)
        time.sleep(200000)
        time.sleep(200000)
        time.sleep(200000)
        time.sleep(200000)

    def tearDown(self):
        self.driver.close()

if __name__ == "__main__":
    unittest.main()

image

Driver fails to connect with the browser main page

Hello ,
I try to communicate with the page content via javascript but it looks like the driver doesnt work in the same context as the main page.For example navigating to google and trying to read a var that already exists in the page will throw an exception.The same piece of code works fine in all other drivers.
I used wires 0.7.1 , and tried firefox 46 & 47.
Thanks

@test
public void test1() throws Exception{
WebDriver _driver;
DesiredCapabilities dc = DesiredCapabilities.firefox();
OSUtils.setSystemProperty("webdriver.firefox.bin", "C:\FirefoxOfficial\firefox.exe");
OSUtils.setSystemProperty("webdriver.gecko.driver","C:\Wires\wires.exe");
_driver = new MarionetteDriver(dc);
_driver.navigate().to("https://www.google.com/");
Thread.sleep(2000);
JavascriptExecutor jx = (JavascriptExecutor) _driver;
Object varNum = jx.executeScript("return gadgets;");
System.out.println(varNum);
}

This is the output:

org.openqa.selenium.WebDriverException: ReferenceError: gadgets is not defined (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 35 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:01:03'
System info: host: 'WALKME200', ip: '192.168.3.155', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_71'
Driver info: org.openqa.selenium.firefox.MarionetteDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, appBuildId=20160502172042, version=46.0.1, platform=XP, proxy={}, specificationLevel=1, acceptSslCerts=false, browserVersion=46.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=Windows_NT, device=desktop}]
Session ID: 397e956c-6a77-4dc3-865c-c3e1f6e76854
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:575)

This is the driver`s log:

1465460585734 Marionette DEBUG Marionette enabled via build flag and pref
1465460585932 Marionette INFO Listening on port 2828
1465460586433 Marionette DEBUG Accepted connection conn0 from 127.0.0.1:62380
1465460586446 Marionette TRACE conn0 -> [0,1,"newSession",{"capabilities":null,"sessionId":null}]
1465460586448 Marionette CONFIG Changing capabilities: {"browserName":"Firefox","browserVersion":"46.0.1","platformName":"Windows_NT","platformVersion":"6.1","specificationLevel":"1","raisesAccessibilityExceptions":false,"rotatable":false,"acceptSslCerts":false,"takesElementScreenshot":true,"takesScreenshot":true,"proxy":{},"platform":"WINDOWS_NT","XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","appBuildId":"20160502172042","device":"desktop","version":"46.0.1"}
1465460586980 Marionette DEBUG loaded listener.js
1465460586984 Marionette DEBUG loaded listener.js
1465460587090 Marionette TRACE conn0 <- [1,1,null,{"sessionId":"15d1b671-ef2a-4e02-b801-a2c3f806fe2f","capabilities":{"browserName":"Firefox","browserVersion":"46.0.1","platformName":"Windows_NT","platformVersion":"6.1","specificationLevel":"1","raisesAccessibilityExceptions":false,"rotatable":false,"acceptSslCerts":false,"takesElementScreenshot":true,"takesScreenshot":true,"proxy":{},"platform":"WINDOWS_NT","XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","appBuildId":"20160502172042","device":"desktop","version":"46.0.1"}}]
1465460587135 Marionette TRACE conn0 -> [0,2,"get",{"url":"https://www.google.com/"}]
1465460588996 Marionette TRACE conn0 <- [1,2,null,{}]
JavaScript warning: https://normandy.cdn.mozilla.net/static/js/bundles/selfrepair-7575f6d27445b45bcffb.js, line 9825: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
1465460593616 Marionette TRACE conn0 -> [0,3,"executeScript",{"args":[],"newSandbox":false,"script":"return gadgets;","scriptTimeout":null,"specialPowers":false}]
1465460593619 Marionette TRACE conn0 <- [1,3,{"error":"javascript error","message":"ReferenceError: gadgets is not defined","stacktrace":"execute_script\ninline javascript, line 0\nsrc: "var __marionetteFunc = function(){return gadgets;};__marionetteFunc.apply(null, __marionetteParams);"\nStack:\n__marionetteFunc@dummy file:0:35\n@dummy file:0:56\n"},null]

Example from the selenium-python documentation fails with wires

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = 'tools/firefox/firefox-bin'

driver = webdriver.Firefox(capabilities=firefox_capabilities)

driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

This test fails with:

Traceback (most recent call last):
  File "asd.py", line 16, in <module>
    assert "No results found." not in driver.page_source
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 464, in page_source
    return self.execute(Command.GET_PAGE_SOURCE)['value']
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 151, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: {"error":"unknown command","message":"GET /session/b4ff4988-2ce7-4cce-85e9-59ab27787d2a/source did not match a known command"}

Getting CSS property always returns empty string

Log sample:
[bdd164c0-2322-41a3-9625-310d1236d73d, getElementValueOfCssProperty {id=fe665d82-651c-40ac-8e68-feea9fe00f6d, propertyName=opacity}]
1441551380774 Marionette DEBUG conn0 -> ({"name":"getElementValueOfCssProperty","parameters":{"id":"fe665d82-651c-40ac-8e68-feea9fe00f6d","name":"opacity"},"sessionId":"bdd164c0-2322-41a3-9625-310d1236d73d","to":"0"})
1441551380791 Marionette DEBUG conn0 client <- ({"from":"0","value":"","status":"success","sessionId":"bdd164c0-2322-41a3-9625-310d1236d73d"})
ERROR:webdriver::server: Returning status Ok
ERROR:webdriver::server: Returning body {"value":""}

Unknown command switchToParentFrame

INFO: Executing: switchToParentFrame [25bcb99d-d896-4bf7-ad69-6c55b39f5b09, switchToParentFrame {}]
1442232825843 Marionette DEBUG conn0 -> {"name":"switchToParentFrame","parameters":{},"sessionId":"25bcb99d-d896-4bf7-ad69-6c55b39f5b09"}
1442232825844 Marionette DEBUG conn0 client <- {"error":"unknown command","message":"switchToParentFrame","stacktrace":null}

Firefox Nightly returns incorrect version

-> POST session
   >>> http://127.0.0.1:4444/session | {"desiredCapabilities":{"browserName":"firefox","version":"","platform":"ANY","javascriptEnabled":true,"cssSelectorsEnabled":true,"takesScreenshot":true,"nativeEvents":false,"rotatable":false,"firefox_binary":"/opt/nightly/firefox-bin","marionette":true}}

<- {"sessionId":"27fec40c-4bd4-4915-b072-5cbfa570b2a9","value":{"XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","acceptSslCerts":false,"appBuildId":"20151221004011","browserName":"Firefox","browserVersion":"45.0a2","device":"desktop","platform":"LINUX","platformName":"Linux","platformVersion":"3.19.0-32-generic","proxy":{},"raisesAccessibilityExceptions":false,"rotatable":false,"specificationLevel":"1","takesElementScreenshot":true,"takesScreenshot":true,"version":"45.0a2"}}

It is properly opening Nightly, but the version is getting reported as 45.0a2

For reference, this is the firefox_binary that is getting passed in:

titus@titus-To-be-filled-by-O-E-M ~/git/selenium $ /opt/nightly/firefox-bin --version
Mozilla Firefox 46.0a1

Forward/Backward Compatibility

It's slightly annoying not to be able to use the latest version of Wires on Firefox 43 & 44

Even worse, when trying to use Wires 4.2 on Firefox 45 or 46, the POST to get a session completely hangs and times out before returning anything (no additional marionette debugging information).

At the very least that needs to be captured so we can add a message to upgrade their version of wires.

Does not close session properly

STR

Start the proxy with:

cargo run -- -b /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin

Get a demo project:

git clone https://github.com/vladikoff/intern-quick-test.git
cd intern-quick-test
npm install
npm test

Firefox Nightly opens.
Close Firefox

run

npm test

Expected

Firefox should start again

Actual

Firefox does not open

wires output

➜  wires git:(docs) cargo run -- -b /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin
     Running `target/debug/wires -b /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin`
ERROR:webdriver::server: Returning status NotFound
ERROR:webdriver::server: Returning body {"message":"POST /wd/hub/session did not match a known command","status":"unknown command"}
ERROR:webdriver::server: Returning status NotFound
ERROR:webdriver::server: Returning body {"message":"POST /wd/hub/session did not match a known command","status":"unknown command"}
ERROR:webdriver::server: Returning status NotFound
ERROR:webdriver::server: Returning body {"message":"POST /wd/hub/session did not match a known command","status":"unknown command"}
ERROR:webdriver::server: Returning status NotFound
ERROR:webdriver::server: Returning body {"message":"POST /wd/hub/session did not match a known command","status":"unknown command"}
^C
➜  wires git:(docs) cargo run -- -b /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin
     Running `target/debug/wires -b /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin`
1439351333612 Marionette  INFO  Marionette enabled via build flag and pref
1439351333758 Marionette  INFO  Listening on port 2828
1439351334059 Marionette  INFO  Marionette enabled via command-line flag
1439351334103 Marionette  INFO  Accepted connection conn0 from 127.0.0.1:49928
1439351334103 Marionette  DEBUG conn0 client <- ({"from":"root","applicationType":"gecko","traits":[]})
1439351334143 Marionette  DEBUG conn0 -> ({"name":"getMarionetteID","to":"root"})
1439351334144 Marionette  DEBUG conn0 client <- ({"from":"root","id":"0"})
1439351334147 Marionette  DEBUG conn0 -> ({"name":"newSession","parameters":{"capabilities":null,"sessionId":null},"to":"0"})
1439351334958 Marionette  INFO  loaded listener.js
1439351334962 Marionette  INFO  loaded listener.js
Shumway is registered
-*- PushService.jsm: init()
-*- PushService.jsm: new state: 2 old state: 0
-*- PushService.jsm: init()
-*- PushService.jsm: changeServerURL
-*- PushService.jsm: startService
-*- PushServiceWebSocket.jsm: init()
-*- PushService.jsm: startObservers
-*- PushService.jsm: changeStateConnectionEnabledEvent: true
-*- PushService.jsm: changeStateOfflineEvent: false
-*- PushDB.jsm: getAllUnexpired()
-*- PushDB.jsm: getAllByPushQuota()
-*- PushService.jsm: new state: 5 old state: 2
1439351335089 Marionette  DEBUG conn0 client <- ({"from":"0","value":{"browserName":"Firefox","browserVersion":"43.0a1","platformName":"DARWIN","platformVersion":"43.0a1","raisesAccessibilityExceptions":false,"rotatable":false,"acceptSslCerts":false,"takesElementScreenshot":true,"takesScreenshot":true,"proxy":{},"platform":"DARWIN","XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","appBuildId":"20150811030206","device":"desktop","version":"43.0a1"},"status":"success","sessionId":"{48b7f846-90e4-af41-a257-cde47453a0e5}"})
ERROR:webdriver::server: Returning status Ok
ERROR:webdriver::server: Returning body {"sessionId":"{48b7f846-90e4-af41-a257-cde47453a0e5}","value":{"XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","acceptSslCerts":false,"appBuildId":"20150811030206","browserName":"Firefox","browserVersion":"43.0a1","device":"desktop","platform":"DARWIN","platformName":"DARWIN","platformVersion":"43.0a1","proxy":{},"raisesAccessibilityExceptions":false,"rotatable":false,"takesElementScreenshot":true,"takesScreenshot":true,"version":"43.0a1"}}
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}
-*- PushService.jsm: changeStateOfflineEvent: true
-*- PushServiceWebSocket.jsm: shutdownWS()
-*- PushService.jsm: new state: 4 old state: 5
1439351343880 Marionette  INFO  Closed connection conn0
-*- PushService.jsm: uninit()
-*- PushService.jsm: new state: 0 old state: 4
-*- PushService.jsm: shutdown complete!
-*- PushService.jsm: changeServerURL
-*- PushService.jsm: stopService
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Session is already started","status":"unsupported operation"}

wires connects to exsiting Firefox session rather than creating a new one

STR:

  1. Open Firefox
  2. Run snippet below
  3. Note that a new Firefox instance was not opened, the page was loaded in the existing instance
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Applications/FirefoxNightly.app/Contents/MacOS/firefox'
driver = webdriver.Firefox(capabilities=firefox_capabilities)

driver.get('data:text/html,<a href="https://mozilla.org">Click This!</a>')

Implement anon [attribute] locator commands

To be able to access anonymous child nodes of XBL bindings in chrome scope of the browser, we would need a new locator command. If you don't know about anonymous content read up about here.

For accessing anonymous nodes the methods getAnonymousNodes() and getAnonymousElementByAttribute() can be used.

Usage wise getAnonymousElementByAttribute() will be necessary more often given that you want to look for a specific attribute value like anonid or class.

If you are curious how to find out what elements are actually anonymous in Firefox you can install the DOM Inspector. Inspect the main browser window and search for the locationbar (urlbar). Anything which is in red color beneath this node is anonymous content and can only be accessed by the above mentioned methods.

As of right now its not possible to use those methods given that it would require to pass through a dictionary and not only a string. It means there might be some more work to do. But I will leave this up to @jgraham and @AutomatedTester to comment on.

Missing "no such element" error

This should return "no such element" instead of "unknown error"
Marionette DEBUG message has it correct, so it must be getting lost in a conversion?

-> POST session/fb83f9f7-a77f-4b00-a1a3-b6e7b997c496/element
   >>> http://127.0.0.1:4444/session/fb83f9f7-a77f-4b00-a1a3-b6e7b997c496/element | {"using":"css selector","value":"#nonexistant"}

1452045763559   Marionette  DEBUG   conn0 -> Command {id: 3, name: "findElement", parameters: {"using":"css selector","value":"#nonexistant"}}
1452045763562   Marionette  DEBUG   conn0 <- Response {id: 3, error: {"error":"no such element","message":"Unable to locate element: #nonexistant","stacktrace":null}, body: null}

<- {"error":"unknown error","message":"Error value has no status"}

expected Selenium::WebDriver::Error::NoSuchElementError, got #<Selenium::WebDriver::Error::WebDriverError: Error value has no status> with backtrace:

Unexpected alert open error is not returned

According to the spec:

"When a user prompt appears, it is the task of the subsequent command to handle it. If the subsequent requested command is not one listed in this chapter, an unexpected alert open error will be returned."
http://www.w3.org/TR/webdriver/#user-prompts

This Selenium test is designed to check this requirement:

  public void testIncludesAlertTextInUnhandledAlertException() {
    driver.findElement(By.id("alert")).click();
    wait.until(alertIsPresent());
    try {
      driver.getTitle();
      fail("Expected UnhandledAlertException");
    } catch (UnhandledAlertException e) {
      assertEquals("cheese", e.getAlertText());
      assertThat(e.getMessage(), containsString("cheese"));
    }
  }

But it fails due to lack of exception, getTitle command returns the title instead of unexpected alert open error.

Getting the value of a boolean attribute should return true or null

1441559328414 Marionette DEBUG conn0 -> ({"name":"getElementAttribute","parameters":{"id":"7f366da6-405f-4ae6-aae6-0d86e2a6e781","name":"disabled"},"sessionId":"cf570ea6-4056-49b9-ab38-0e63a471d824","to":"0"})
1441559328418 Marionette DEBUG conn0 client <- ({"from":"0","value":"false","status":"success","sessionId":"cf570ea6-4056-49b9-ab38-0e63a471d824"})
ERROR:webdriver::server: Returning status Ok
ERROR:webdriver::server: Returning body {"value":"false"}

A new driver connects to an already existing session of Firefox

1.open a new session of firefox throught the driver .
2.stop the test but leave the firefox window open,
3.run :
@test
public void test1() throws Exception{
WebDriver _driver;
DesiredCapabilities dc = DesiredCapabilities.firefox();
OSUtils.setSystemProperty("webdriver.firefox.bin", "C:\FirefoxOfficial\firefox.exe");
OSUtils.setSystemProperty("webdriver.gecko.driver","C:\Wires\wires.exe");
_driver = new MarionetteDriver(dc);
_driver.navigate().to("https://www.google.com/");
}

The result:
=>
A new session of firefox is opened, but the navigation occurs on the old already exited session.
I used wires 0.7.1 , and tried firefox 46 & 47.

Connection refused attempting to use RemoteWebDriver

I cannot get RemoteWebDriver to work using v0.6.2 or v0.7.1 of GeckoDriver.

Config:
OSX 10.11.4
Selenium 2.53.0
Wires v0.6.2 and 0.7.1

Example using RemoteWebDriver:

System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY, "/temp/wires-0.7.1-OSX");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapabilities("marionette", true);
WebDriver webDriver = new RemoteWebDriver(seleniumHubUrl, capabilities);

This causes a org.openqa.selenium.WebDriverException: Connection refused to be thrown.

I can, however, get it to work using MarionetteDriver.
Example using MarionetteDriver:

System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY, "/temp/wires-0.7.1-OSX");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
MarionetteDriver marionetteDriver = new MarionetteDriver(capabilities);

This successfully opens a Firefox browser.

I need to be able to use RemoteWebDriver so I can utilize our Selenium Grid.

Any help resolving this would be greatly appreciated.

There is no way to use addons

With Selenium FirefoxDriver we can specify a FirefoxProfile and add extensions.

        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.AddExtension(@"path to .xpi");
        FirefoxDriver driver = new FirefoxDriver(firefoxProfile);

However, wires offers no such API. Is there a way to have wires load a users Firefox extensions?

It is not possible to call a function defined on the page

Let there be a page with displayMessage function defined:

INFO: Executing: executeScript [b55293e0-7e98-4cd8-9a71-19f219543449, executeScript {script=displayMessage('I like cheese');, args=[]}]
1441555505357 Marionette DEBUG conn0 -> ({"name":"executeScript","parameters":{"args":[],"newSandbox":false,"script":"displayMessage('I like cheese');","scriptTimeout":null,"specialPowers":false},"sessionId":"b55293e0-7e98-4cd8-9a71-19f219543449","to":"0"})
1441555505359 Marionette DEBUG conn0 client <- ({"from":"0","status":"javascript error","sessionId":"b55293e0-7e98-4cd8-9a71-19f219543449","error":{"message":"ReferenceError: displayMessage is not defined","stacktrace":"\ninline javascript, line 0\nsrc: "let __marionetteFunc = function(){displayMessage('I like cheese');};__marionetteFunc.apply(null, __marionetteParams);"","status":"javascript error"}})
ERROR:webdriver::server: Returning status InternalServerError
ERROR:webdriver::server: Returning body {"message":"Marionette Error: ReferenceError: displayMessage is not defined","status":"javascript error"}

Find Elements broken

The latest wires release is giving me the following in both nightly & developer

-> POST session/685f8c96-ec23-4f58-b76e-9d80cab6d43f/elements
   >>> http://localhost:4444/session/685f8c96-ec23-4f58-b76e-9d80cab6d43f/elements | {"using":"css selector","value":".nameC"}
<- {"error":"unknown error","message":"Expected object params"}

set_window_size does not work properly

  1. It fails with Connection reset by peer
----> 1 ff.set_window_size(1000, 1000)

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in set_window_size(self, width, height, windowHandle)
    834             command = Command.W3C_SET_WINDOW_SIZE
    835         self.execute(command, {'width': int(width), 'height': int(height),
--> 836           'windowHandle': windowHandle})
    837 
    838     def get_window_size(self, windowHandle='current'):

/usr/local/lib/python2.7/site-packages/Selenium2Library/webdrivermonkeypatches.pyc in execute(self, driver_command, params)
      9 
     10     def execute(self, driver_command, params=None):
---> 11         result = self._base_execute(driver_command, params)
     12         speed = self._get_speed()
     13         if speed > 0:

/Users/dm08/projects/zeus/aphrodite/src/AphroditeLibrary/webdrivermonkeypatches.pyc in execute(self, driver_command, params)
     22                 time.sleep(1)
     23 
---> 24         return self._base_execute2(driver_command, params)
     25 
     26     def is_page_loading(self):

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in execute(self, driver_command, params)
    229 
    230         params = self._wrap_value(params)
--> 231         response = self.command_executor.execute(driver_command, params)
    232         if response:
    233             self.error_handler.check_response(response)

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.pyc in execute(self, command, params)
    393         path = string.Template(command_info[1]).substitute(params)
    394         url = '%s%s' % (self._url, path)
--> 395         return self._request(command_info[0], url, body=data)
    396 
    397     def _request(self, method, url, body=None):

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.pyc in _request(self, method, url, body)
    424             try:
    425                 self._conn.request(method, parsed_url.path, body, headers)
--> 426                 resp = self._conn.getresponse()
    427             except (httplib.HTTPException, socket.error):
    428                 self._conn.close()

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in getresponse(self, buffering)
   1130 
   1131         try:
-> 1132             response.begin()
   1133             assert response.will_close != _UNKNOWN
   1134             self.__state = _CS_IDLE

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in begin(self)
    451         # read until we get a non-100 response
    452         while True:
--> 453             version, status, reason = self._read_status()
    454             if status != CONTINUE:
    455                 break

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in _read_status(self)
    407     def _read_status(self):
    408         # Initialize with Simple-Response defaults
--> 409         line = self.fp.readline(_MAXLINE + 1)
    410         if len(line) > _MAXLINE:
    411             raise LineTooLong("header line")

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc in readline(self, size)
    478             while True:
    479                 try:
--> 480                     data = self._sock.recv(self._rbufsize)
    481                 except error, e:
    482                     if e.args[0] == EINTR:

error: [Errno 54] Connection reset by peer

In [18]: ff.set_window_size(1000, 1000)

In [19]: ff.set_window_size(1000, 1000)
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-19-c6fe6880f545> in <module>()
----> 1 ff.set_window_size(1000, 1000)

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in set_window_size(self, width, height, windowHandle)
    834             command = Command.W3C_SET_WINDOW_SIZE
    835         self.execute(command, {'width': int(width), 'height': int(height),
--> 836           'windowHandle': windowHandle})
    837 
    838     def get_window_size(self, windowHandle='current'):

/usr/local/lib/python2.7/site-packages/Selenium2Library/webdrivermonkeypatches.pyc in execute(self, driver_command, params)
      9 
     10     def execute(self, driver_command, params=None):
---> 11         result = self._base_execute(driver_command, params)
     12         speed = self._get_speed()
     13         if speed > 0:

/Users/dm08/projects/zeus/aphrodite/src/AphroditeLibrary/webdrivermonkeypatches.pyc in execute(self, driver_command, params)
     22                 time.sleep(1)
     23 
---> 24         return self._base_execute2(driver_command, params)
     25 
     26     def is_page_loading(self):

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in execute(self, driver_command, params)
    229 
    230         params = self._wrap_value(params)
--> 231         response = self.command_executor.execute(driver_command, params)
    232         if response:
    233             self.error_handler.check_response(response)

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.pyc in execute(self, command, params)
    393         path = string.Template(command_info[1]).substitute(params)
    394         url = '%s%s' % (self._url, path)
--> 395         return self._request(command_info[0], url, body=data)
    396 
    397     def _request(self, method, url, body=None):

/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.pyc in _request(self, method, url, body)
    424             try:
    425                 self._conn.request(method, parsed_url.path, body, headers)
--> 426                 resp = self._conn.getresponse()
    427             except (httplib.HTTPException, socket.error):
    428                 self._conn.close()

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in getresponse(self, buffering)
   1130 
   1131         try:
-> 1132             response.begin()
   1133             assert response.will_close != _UNKNOWN
   1134             self.__state = _CS_IDLE

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in begin(self)
    451         # read until we get a non-100 response
    452         while True:
--> 453             version, status, reason = self._read_status()
    454             if status != CONTINUE:
    455                 break

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in _read_status(self)
    407     def _read_status(self):
    408         # Initialize with Simple-Response defaults
--> 409         line = self.fp.readline(_MAXLINE + 1)
    410         if len(line) > _MAXLINE:
    411             raise LineTooLong("header line")

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc in readline(self, size)
    478             while True:
    479                 try:
--> 480                     data = self._sock.recv(self._rbufsize)
    481                 except error, e:
    482                     if e.args[0] == EINTR:

error: [Errno 54] Connection reset by peer

  1. It raises WebDriverException: Message: Invalid requested size, cannot maximize randomly
    it does not matter if screen size is smaller, bigger or the same as screen resolution

Tested on
Os:

  • Mac OSX El Captain
  • Amazon Linux

Browser:

  • Mozilla Firefox 45.0.1 (osx)
  • Mozilla Firefox 45.0 (linux)

Selenium:
2.53.1 - python

Wires

  • wires-0.6.2-linux64
  • wires-0.6.2-OSX

Can't set preferences with selenium-python

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys

firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("general.useragent.override", "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0")

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = 'tools/firefox/firefox-bin'

driver = webdriver.Firefox(firefox_profile=firefox_profile, capabilities=firefox_capabilities)

This works (i.e. the user agent is changed) if I remove the capabilities part.

NoSuchFrameException: Message: frame id has unexpected type

STR

Prepare a marionette setting

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Users/vladikoff/mozilla/mercurial/fx-team/objdir-frontend/dist/Nightly.app/Contents/MacOS/firefox'

Test script

    def setUp(self):
        self.driver = webdriver.Firefox(capabilities=firefox_capabilities)
        self.driver.implicitly_wait(20)  # seconds

    def test_fxa_test(self):
        email = "fxatester" + str(random.random()) + "@restmail.net"

        self.driver.get("about:preferences#sync")
        elem = self.driver.find_element_by_css_selector("#noFxaSignUp")
        elem.click()

        self.driver.switch_to.frame("remote")

Expected

Should be able to switch to the iframe on the about:accounts page.

This works in stable Firefox without setting firefox_capabilities['marionette'] = True

Actual


Error
Traceback (most recent call last):
  File "/Users/vladikoff/PycharmProjects/fxa-sync-e2e/tests/test_signup.py", line 40, in test_fxa_test
    self.driver.switch_to.frame("remote")
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/switch_to.py", line 67, in frame
    self._driver.execute(Command.SWITCH_TO_FRAME, {'id': frame_reference})
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 188, in check_response
    raise exception_class(message, screen, stacktrace)
NoSuchFrameException: Message: frame id has unexpected type

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.