Mocha + SeleniumJS + PhantomJS 检索超时

Mocha + SeleniumJS + PhantomJS retrieves timeout

我正在使用 Mocha + SeleniumJS,使用 webdriver(不是独立安装)和 Mocha 作为测试框架 脚本在 MAC OS 上 运行 正常,但是当我尝试使用 Windows 服务器时,它们开始失败。

这是尝试创建新的网络驱动程序会话并导航到作为参数发送的 URL 的脚本。

*exports.goToPage = function(Url) {
        var capabilities = {
        'browserName' : 'phantomjs',
        'phantomjs.binary.path' : './node_modules/.bin/phantomjs.cmd',
        'phantomjs.page.settings.userAgent' : +userAgent,
        'phantomjs.cli.args' : ['--debug=true --webdriver-loglevel=DEBUG --port=30000']
        };
        browser = new webdriver.Builder().usingServer().withCapabilities(capabilities).build();
    }
    browser.manage().timeouts().implicitlyWait(8000);
    browserOpen = 1;
    return browser.get(Url).then(function() {
        //opts.addArguments("--start-maximized");
        //driver = new ChromeDriver( options );
        browser.sleep(10000);
    });
};*

脚本 运行 使用:

摩卡Frontend/test/categoriesTest.js

错误:

Uncaught Error: Timed out waiting for the WebDriver server at http://10.11.100.211:52242/

     at Error (<anonymous>)
     at Socket.socketErrorListener (http.js:1552:9)
     at net.js:441:14


==== async task ====
 WebDriver.createSession() at Object.exports.goToPage (C:\J\dev-smoke-tests\functionalAPI.js:35:83) 
at Context.<anonymous> (C:\J\dev-smoke-tests\Frontend\test\categoriesTest.js:24:7)

usingServer() url WebDriver 服务器的位置。如果您不打算使用自定义服务器,那么我建议您将其删除。

官方文档是这样说的:

Sets the URL of a remote WebDriver server to use. Once a remote URL has been specified, the builder direct all new clients to that server. If this method is never called, the Builder will attempt to create all clients locally.

As an alternative to this method, you may also set the SELENIUM_REMOTE_URL environment variable.