基本testing在夜视phantomjs浏览器上失败
我正在使用selenium服务器,node.js和phantomjsselenium的夜间守夜。 我使用phantomjs只是为了无头浏览器(当它运行testing时selenium并不打开浏览器)。
当我使用firefox作为浏览器时,我的基本testing通过,但是当我使用phantomjs浏览器时失败。
我设置基本的谷歌testing:
module.exports = { 'Demo test Google' : function (browser) { browser .url('http://www.google.com') .waitForElementVisible('body', 1000) .setValue('input[type=text]', 'nightwatch') .waitForElementVisible('button[name=btnG]', 1000) .click('button[name=btnG]') .pause(1000) .assert.containsText('#main', 'Night Watch') .end(); } };
并设置phantomjs服务器。 这是我的nightwatch.json:
{ "src_folders" : ["tests"], "output_folder" : "reports", "custom_commands_path" : "", "custom_assertions_path" : "", "page_objects_path" : "", "globals_path" : "", "selenium" : { "start_process" : false, "server_path" : "selenium-server-standalone-2.53.1.jar", "log_path" : "", "host" : "127.0.0.1", "port" : 3001, "cli_args" : { "webdriver.chrome.driver" : "", "webdriver.ie.driver" : "" } }, "test_settings" : { "default" : { "launch_url" : "http://localhost", "selenium_port" : 3001, "selenium_host" : "localhost", "silent": true, "screenshots" : { "enabled" : false, "path" : "" }, "desiredCapabilities": { "browserName": "phantomjs", "javascriptEnabled": true, "acceptSslCerts": true, "phantomjs.binary.path" : "phantomjs.exe" } } } }
当我将browserName设置为“firefox”时,testing通过,“OK。3断言通过”。 但是当它是“phantomjs”时,在执行过程中,一个失败,一个错误,一个错误:“testing失败:执行期间1个错误,1个断言失败,1个通过(3.511s)”。
有错误:
-
在等待元素出现1000毫秒时超时。 – 预计“可见”,但得到:“未find”
-
错误:无法find元素:“input [type = text]”using:css selector
我手动启动服务器。
我用最新版本的phantomjs(2.1.1)和1.9.8进行了testing
编辑:
Selenium服务器在使用phantomjs时也会报告这个错误:
WebElementLocator – _handleLocateCommand – 找不到的元素:GAVE UP。
过去我曾经为这样的东西埋下了隐患,并且观察到phantomjs浏览器的默认大小非常小。 你可以请尝试调整浏览器大小,并检查发生了什么。
像下面的东西,
module.exports = { 'Demo test Google' : function (browser) { browser .url('http://www.google.com') .resizeWindow(1000, 800); .waitForElementVisible('body', 1000) .setValue('input[type=text]', 'nightwatch') .waitForElementVisible('button[name=btnG]', 1000) .click('button[name=btnG]') .pause(1000) .assert.containsText('#main', 'Night Watch') .end(); } };
- 使用Rtmp将videostream式传输到stream媒体服务
- 我在哪里可以find常见Node.js模块的发行说明/更新日志
- 尝试安装grunt-sass时,“node build.js”失败
- “process.stdin.on”中的“.on”在哪里?
- ReactDOMServer.renderToString不是一个函数
- Node.js缓冲区和二进制文件
- GET https://127.0.0.1:9000/peerjs/peerjs/id?ts=14993271469660.591159722513086 net :: ERR_CONNECTION_REFUSED
- 按顺序调用JavaScript代码的另一种方法是在两者之间拖延
- Grunt Compass致命错误:产卵EPERM