Firefox不从Selenium Grid NodeConfig获取配置文件

时间:2018-06-28 09:00:55

标签: selenium selenium-webdriver selenium-grid selenium-firefoxdriver firefox-marionette

我在nodeconfig.json中指定了firefox使用默认配置文件,而不是每次都创建一个新的配置文件。

但是,它仍然每次都会创建一个新的配置文件,如第3行所示

1530174032396   geckodriver     INFO    geckodriver 0.20.1 (685f18325cea0a282c736e65972f95aa6db7ca48 2018-04-03)
1530174032423   geckodriver     INFO    Listening on 127.0.0.1:41007
1530174032522   mozrunner::runner       INFO    Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\lharries\\AppData\\Local\\Temp\\rust_mozprofile.wIKc55QUmufr"
1530174040955   Marionette      INFO    Listening on port 2714
09:20:41.125 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
09:20:41.208 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session e22e831e-4393-43f1-9d77-b6bd894a6f32 (org.openqa.selenium.firefox.GeckoDriverService)
1530174056358   addons.productaddons    WARN    Failed downloading XML, status: 0, reason: error
1530174056771   addons.productaddons    WARN    Failed downloading via XHR, status: 0, reason: error
[Child 28464, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346

下面是我的nodeConfig.JSON

我在浏览器详细信息之后的第二行中放置了“ webdriver.firefox.profile”:“默认”。

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "version": "60",
      "platform": "Windows 10",
      "seleniumProtocol": "WebDriver",
      "maxInstances": 8
    },
    {
      "browserName": "chrome",
      "version": "66",
      "platform": "Windows 10",
      "seleniumProtocol": "WebDriver",
      "maxInstances": 8
    },
    {
      "browserName": "internet explorer",
      "version": "11",
      "seleniumProtocol": "WebDriver",
      "maxInstances": 5
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",   
  "webdriver.firefox.profile":"default",
  "maxSession": 8,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://localhost:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

这是我创建驱动程序对象的方式,DriverConfig是我创建的用于从应用程序设置中提取信息的类。

        ICapabilities caps = new DesiredCapabilities();

        //generic Desktop Browser config':
        if (DriverConfig.BrowserName != "")
        { ((DesiredCapabilities)caps).SetCapability("browserName", DriverConfig.BrowserName); }
        else
        { }
        if (DriverConfig.Version != "")
        { ((DesiredCapabilities)caps).SetCapability("version", DriverConfig.Version); }
        else
        { }
        if (DriverConfig.Platform != "")
        { ((DesiredCapabilities)caps).SetCapability("platform", DriverConfig.Platform); }
        else
        { }

        Instance = new RemoteWebDriver(new Uri(DriverConfig.BrowserExecutionAddress), caps);

        // Maximise the window for consistency
        Instance.Manage().Window.Maximize();

        // Go to the start URL
        Instance.Navigate().GoToUrl(DriverConfig.BrowserStartURL);

更新:

我也尝试按照功能示例https://github.com/mozilla/geckodriver#capabilities-example进行操作

更新了nodeConfig.json

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "version": "60",
      "platform": "Windows 10",
      "seleniumProtocol": "WebDriver",
      "maxInstances": 8,
        "alwaysMatch": {
            "moz:firefoxOptions": {
                "args": ["-profile", "C://SeleniumGrid//Profiles//1tzit6yx.Automation"]
            }
        }
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", 
  "maxSession": 8,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://localhost:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

我尝试了以下使用配置来设置网格的方法

java -jar SeleniumJars/selenium-server-standalone-3.12.0.jar -role node -nodeConfig nodeconfigFF.json
java -Dwebdriver.firefox.profile=Automation -jar SeleniumJars/selenium-server-standalone-3.12.0.jar -role node -nodeConfig nodeConfigFF.json
java -Dwebdriver.firefox.profile="C://SeleniumGrid//Profiles//1tzit6yx.Automation" -jar SeleniumJars/selenium-server-standalone-3.12.0.jar -role node -nodeConfig nodeConfigFF.json

所有连接和呼叫浏览器,但所有浏览器仍会临时创建配置文件

0 个答案:

没有答案