mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.2k stars 1.52k forks source link

webDriver.manage().window().setPosition does not work - null values in geckodriver::marionette #724

Closed elliottj closed 7 years ago

elliottj commented 7 years ago

VERSIONS Firefox version: 53.0 (64-bit) GeckoDriver: v0.16.1 win64 Selenium: 3.4.0 Java bindings NetBeans: 8.1 Java jdk1.8.0_73

PLATFORM Windows 7 64 bit 16GB RAM

I've setup a simple maven project to launch Firefox and re-position the window, which does not work

CODE

    public static void main(String[] args)
    {
        System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe");
        FirefoxOptions options = new FirefoxOptions();
        options.setLogLevel(Level.ALL);
        WebDriver webDriver = new FirefoxDriver(options);
        webDriver.manage().window().setPosition(new Point(2000, 0));
        webDriver.close();
    }

EXPECTED Firefox launches and is moved to a new position.

ACTUAL The window position does not change. Console output below shows null values in marionette trace:

1494252228013   webdriver::server   DEBUG   → POST /session/ae330d35-ee5b-4672-9447-b4abc0b1cf56/window/rect {"script":"window.screenX = arguments[0]; window.screenY = arguments[1]","args":[2000,0]}
1494252228013   geckodriver::marionette TRACE   → 68:[0,2,"setWindowRect",{"height":null,"width":null,"x":null,"y":null}]

FULL CONSOLE OUTPUT

NetBeans: JPDA Listening Start...
JPDA Address: mtlelj01:54375
Port:54375
cd C:\GIT\firefoxdemo; JAVA_HOME=C:\\Java\\jdk1.8.0_73 cmd /c "\"\"C:\\Program Files\\NetBeans 8.1\\java\\maven\\bin\\mvn.bat\" -Dexec.args=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=54375 -classpath %classpath com.mycompany.firefoxdemo.Demo\" -Dexec.executable=C:\\Java\\jdk1.8.0_73\\bin\\java.exe -Djpda.listen=true -Djpda.address=54375 -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.1\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...

------------------------------------------------------------------------
Building firefoxdemo 1.0-SNAPSHOT
------------------------------------------------------------------------
Downloading: http://xxx/nexus/content/groups/public/org/seleniumhq/selenium/selenium-api/maven-metadata.xml

Downloaded: http://xxx/nexus/content/groups/public/org/seleniumhq/selenium/selenium-api/maven-metadata.xml (3 KB at 28.7 KB/sec)
Downloading: http://xxx/nexus/content/groups/public/org/seleniumhq/selenium/selenium-support/maven-metadata.xml

Downloaded: http://xxx/nexus/content/groups/public/org/seleniumhq/selenium/selenium-support/maven-metadata.xml (4 KB at 98.1 KB/sec)

--- exec-maven-plugin:1.2.1:exec (default-cli) @ firefoxdemo ---
1494252218995   geckodriver INFO    Listening on 127.0.0.1:18297
1494252219640   geckodriver::marionette INFO    Starting browser \\?\C:\Program Files\Mozilla Firefox\firefox.exe with args ["-marionette"]
1494252219877   addons.manager  ERROR   startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70"  data: no] Stack trace: FileUtils_getDir()@resource://gre/modules/FileUtils.jsm:70 < FileUtils_getFile()@JavarScript error: resourcee:so/u/rgcree://m/gre/moodduulleess//AFdidloenUMtainlasg.ejrs.mj:s4m2,  <l ivnael i1d657: NS_ERROR_NOT_INITIALIZED: aAtdedBolnoMcaknlaigsetr( )i@rse snooutr cien:i/t/igarlei/zmeodd
u
les/AddonManager.jsm:671 < startup()@resource://gre/modules/AddonManager.jsm:834 < startup()@resource://gre/modules/AddonManager.jsm:3129 < observe()@resource://gre/components/addonManager.js:65
1494252220164   Marionette  DEBUG   Marionette enabled via command-line flag
1494252221322   Marionette  INFO    Listening on port 54380
JavaScript error: resource://gre/modules/AddonManager.jsm, line 2570: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
1494252221666   geckodriver::marionette DEBUG   Connected to Marionette on localhost:54380
1494252221675   Marionette  DEBUG   Accepted connection conn0 from 127.0.0.1:54385
1494252221676   geckodriver::marionette TRACE   � {"applicationType":"gecko","marionetteProtocol":3}
1494252221676   geckodriver::marionette TRACE   → 62:[0,1,"newSession",{"capabilities":{"desiredCapabilities":{}}}]
1494252221680   Marionette  TRACE   conn0 -> [0,1,"newSession",{"capabilities":{"desiredCapabilities":{}}}]
1494252221687   Marionette  CONFIG  Matched capabilities: {"browserName":"firefox","browserVersion":"53.0","platformName":"windows_nt","platformVersion":"6.1","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":6492,"moz:profile":"C:\\Users\\mtlelj\\AppData\\Local\\Temp\\rust_mozprofile.99OFInTxgyYv","moz:accessibilityChecks":false}
1494252221710   Marionette  DEBUG   loaded listener.js
1494252221726   Marionette  TRACE   conn0 <- [1,1,null,{"sessionId":"ae330d35-ee5b-4672-9447-b4abc0b1cf56","capabilities":{"browserName":"firefox","browserVersion":"53.0","platformName":"windows_nt","platformVersion":"6.1","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":6492,"moz:profile":"C:\\Users\\mtlelj\\AppData\\Local\\Temp\\rust_mozprofile.99OFInTxgyYv","moz:accessibilityChecks":false}}]
1494252221731   geckodriver::marionette TRACE   � [1,1,null,{"sessionId":"ae330d35-ee5b-4672-9447-b4abc0b1cf56","capabilities":{"browserName":"firefox","browserVersion":"53.0","platformName":"windows_nt","platformVersion":"6.1","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":6492,"moz:profile":"C:\\Users\\mtlelj\\AppData\\Local\\Temp\\rust_mozprofile.99OFInTxgyYv","moz:accessibilityChecks":false}}]
1494252221731   webdriver::server   DEBUG   � 200 OK {"value": {"sessionId":"ae330d35-ee5b-4672-9447-b4abc0b1cf56","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"53.0","moz:accessibilityChecks":false,"moz:processID":6492,"moz:profile":"C:\\Users\\mtlelj\\AppData\\Local\\Temp\\rust_mozprofile.99OFInTxgyYv","pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"6.1","rotatable":false,"specificationLevel":0,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
May 08, 2017 3:03:41 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
1494252228013   webdriver::server   DEBUG   → POST /session/ae330d35-ee5b-4672-9447-b4abc0b1cf56/window/rect {"script":"window.screenX = arguments[0]; window.screenY = arguments[1]","args":[2000,0]}
1494252228013   geckodriver::marionette TRACE   → 68:[0,2,"setWindowRect",{"height":null,"width":null,"x":null,"y":null}]
1494252228014   Marionette  TRACE   conn0 -> [0,2,"setWindowRect",{"height":null,"width":null,"x":null,"y":null}]
1494252228015   Marionette  TRACE   conn0 <- [1,2,null,{"x":4,"y":4,"width":1280,"height":829}]
1494252228016   geckodriver::marionette TRACE   � [1,2,null,{"x":4,"y":4,"width":1280,"height":829}]
1494252228016   webdriver::server   DEBUG   � 200 OK {"value": {}}
1494252253929   webdriver::server   DEBUG   → DELETE /session/ae330d35-ee5b-4672-9447-b4abc0b1cf56/window 
1494252253929   geckodriver::marionette TRACE   → 16:[0,3,"close",{}]
1494252253925   Marionette  TRACE   conn0 -> [0,3,"close",{}]
1494252253927   Marionette  TRACE   conn0 <- [1,3,null,[]]
1494252253934   geckodriver::marionette TRACE   � [1,3,null,[]]
1494252253934   webdriver::server   DEBUG   Last window was closed, deleting session
1494252253934   webdriver::server   DEBUG   Deleting session
1494252253934   geckodriver::marionette DEBUG   Stopping browser process
1494252254000   webdriver::server   DEBUG   � 200 OK {"value": []}
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
andreastt commented 7 years ago

Judging by the log output you attached, it does not look like your client binding is sending the correct message format:

1494252228013   webdriver::server   DEBUG   → POST /session/ae330d35-ee5b-4672-9447-b4abc0b1cf56/window/rect {"script":"window.screenX = arguments[0]; window.screenY = arguments[1]","args":[2000,0]}
1494252228013   geckodriver::marionette TRACE   → 68:[0,2,"setWindowRect",{"height":null,"width":null,"x":null,"y":null}]

It looks like it is sending the message of an injected script to the Set Window Rect command endpoint, which won’t work for obvious reasons.

Do you mind filing a bug with Selenium?

BrandonDudek commented 7 years ago

See: https://github.com/mozilla/geckodriver/issues/676

lock[bot] commented 5 years ago

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.