nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.79k stars 1.31k forks source link

.execute() protocol action does not work on Firefox #1791

Closed gettingtired closed 6 years ago

gettingtired commented 6 years ago

Tried running my script on firefox and got this response from verbose logging. Selenium v3.11.0, Firefox v59.0.2, Nightwatch v1.0.4

Request POST http://selenium-docker:4445/wd/hub/session/8a183f25-3d58-436e-8ce5-b46af3c5c220/execute

        { script: 'return document.readyState;', args: [] }

Response 404 POST http://selenium-docker:4445/wd/hub/session/8a183f25-3d58-436e-8ce5-b46af3c5c220/execute (654ms)

        { value: 
            { error: 'unknown command',
                message: 'POST /session/8a183f25-3d58-436e-8ce5-b46af3c5c220/execute did not match a known command',
                stacktrace: '' } }

Error while running .executeScript() protocol action: POST /session/8a183f25-3d58-436e-8ce5-b46af3c5c220/execute did not match a known command

Everything works on chrome as expected.

beatfactor commented 6 years ago

Kindly post your config as well and the contents of geckodriver.log.

Also, please try running Firefox without Selenium, if possible, like so (docs will be updated soon):

{
      "desiredCapabilities" : {
        "browserName" : "firefox",
        "acceptInsecureCerts": true
      },

      "webdriver": {
        "server_path": "/PATH/TO/geckodriver",
        "cli_args": [
          "--log", "debug"
        ]
      }
}
gettingtired commented 6 years ago
{
  "src_folders": [
    "C:\\Users\\kcid\\nightwatch\\scripts"
  ],
  "custom_commands_path": "C:\\Users\\nightwatch\\custom-commands",
  "custom_assertions_path": "C:\\Users\\kcid\\nightwatch\\custom-assertions",
  "waitForConditionPollInterval": 200,
  "test_settings": {
    "default": {
      "selenium": {
        "start_process": false,
        "host": "selenium-docker.service.ccp.org",
        "port": "4445"
      },
      "silent": true,
      "disable_colors": true,
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "acceptInsecureCerts": true,
        "elementScrollBehavior": 1
      },
      "request_timeout_options": {
        "timeout": 300000
      }
    }
  }
}
gettingtired commented 6 years ago

I am using zalenium as a selenium server, here is the logs from geckodriver

1525424310898   geckodriver INFO    geckodriver 0.20.1
1525424310924   geckodriver INFO    Listening on 127.0.0.1:17489
1525424311009   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.Ib0xHTJgYR5u"
1525424312366   Marionette  INFO    Enabled via --marionette
1525424315212   Marionette  INFO    Listening on port 40512
JavaScript error: resource://gre/modules/ProfileAge.jsm, line 176: Error: Unable to fetch oldest profile entry: Unix error 2 during operation lstat on file /tmp/rust_mozprofile.Ib0xHTJgYR5u (No such file or directory)
JavaScript error: resource://gre/modules/ProfileAge.jsm, line 176: Error: Unable to fetch oldest profile entry: Unix error 2 during operation lstat on file /tmp/rust_mozprofile.Ib0xHTJgYR5u (No such file or directory)
1525424316114   Marionette  WARN    TLS certificate errors will be ignored for this session
1525424333526   addons.xpi  WARN    Exception running bootstrap method shutdown on activity-stream@mozilla.org: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://activity-stream/lib/SnippetsFeed.jsm :: uninit :: line 125"  data: no] Stack trace: uninit()@resource://activity-stream/lib/SnippetsFeed.jsm:125 < onAction()@resource://activity-stream/lib/SnippetsFeed.jsm:141 < _middleware/ jar:file:///opt/firefox/browser/features/activity-stream@mozilla.org.xpi!/bootstrap.js:80 < shutdown()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///opt/firefox/browser/features/activity-stream@mozilla.org.xpi!/bootstrap.js:196 < callBootstrapMethod()@resource://gre/modules/addons/XPIProvider.jsm:4419 < observe()@resource://gre/modules/addons/XPIProvider.jsm:2279 < GeckoDriver.prototype.quit()@driver.js:3270 < despatch()@server.js:557 < execute()@server.js:531 < onPacket/<()@server.js:506 < onPacket()@server.js:505 < _onJSONObjectReady/<()@transport.js:500
*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping
gettingtired commented 6 years ago

Also setWindowSize isn't working I can't see the /window/current/size endpoint here https://www.w3.org/TR/webdriver/#list-of-endpoints

Request POST http://seleniumserver:4445/wd/hub/session/49d9ee1e-c659-4701-b633-522d5f163dae/window/current/size  

   { width: 1920, height: 1080 }

Response 404 POST http://seleniumserver:4445/wd/hub/session/49d9ee1e-c659-4701-b633-522d5f163dae/window/current/size (639ms)

   { value:                                                          
      { error: 'unknown command',                                                  
        message: 'POST /session/49d9ee1e-c659-4701-b633-522d5f163dae/window/current/size did not match a known command',                                              
        stacktrace: '' } }

Error while running .setWindowSize() protocol action: POST /session/49d9ee1e-c659-4701-b633-522d5f163dae/window/current/size did not match a known command

But this stuff works in chrome.

beatfactor commented 6 years ago

Yes, setWindowSize is not supported in GeckoDriver at the moment. This is a different issue.

beatfactor commented 6 years ago

The .execute() support has been added in v1.0.10.