2017-04-21 39 views
0

我正在使用Selenium WebDriver API的节点封装程序Nightwatch构建一套自动化集成测试。我能够正常使用Chrome,但不适用于Firefox(或Safari,对此)。当使用Nightwatch和Selenium测试本地主机时,无法在Firefox上加载页面

我认为这个问题与GeckoDriver与Firefox驱动程序有关。我已配置Nightwatch在我的nightwatch.json中使用GeckoDriver。但Selenium似乎在寻找基于终端输出nightwatch -e firefox --verbose的Firefox Driver。请看下图:

INFO Request: POST /wd/hub/session/2c156cf4-10cb-44b2-8b1f-c12312b4633f/url 
- data: {"url":"localhost:9000"} 
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":24} 
ERROR Response 500 POST /wd/hub/session/2c156cf4-10cb-44b2-8b1f-c12312b4633f/url (1218ms) { state: 'unknown error', 
    sessionId: '2c156cf4-10cb-44b2-8b1f-c12312b4633f', 
    hCode: 1111219279, 
    value: 
    { additionalInformation: '\nDriver info: org.openqa.selenium.firefox.FirefoxDriver\nCapabilities ... 

这里是我的Nightwatch配置文件:

{ 
    "src_folders": ["./nightwatch/tests"], 
    "output_folder": "./nightwatch/reports", 
    "custom_commands_path": "", 
    "custom_assertions_path": "", 
    "page_objects_path": "./nightwatch/tests/pages", 
    "globals_path": "", 

    "selenium": { 
    "start_process": true, 
    "server_path": "./nightwatch/selenium-server-standalone-3.4.0.jar", 
    "log_path": false, 
    "cli_args": { 
     "webdriver.chrome.driver": "./nightwatch/drivers/chromedriver", 
     "webdriver.gecko.driver": "./nightwatch/drivers/geckodriver" 
    } 
    }, 

    "test_settings": { 
    "default": { 
     "desiredCapabilities": { 
     "javascriptEnabled": true, 
     "acceptSslCerts": true 
     } 
    }, 

    "chrome": { 
     "desiredCapabilities": { 
     "browserName": "chrome" 
     } 
    }, 

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

和良好的措施,这里是nightwatch/pages/index.js文件我试图访问在我的测试:

module.exports = { 
    url: 'localhost:9000', 
    elements: { 
    // stuff 
    } 
} 

回答

0

对于它的价值,目前我们决定坚持使用当前的ESR版本的Firefox,它与Selenium开箱即用。

我们对这个新版本的Firefox和新驱动做了一些尝试,但它不够稳定,无法继续。

我的建议是安装Firefox的ESR版本,看看你能否以这种方式工作。如果确实如此,则转到下一步(即,测试最新版本)。

相关问题