var c = require('./config'); module.exports = function () { this.When(/^I try to login with wrong credentials$/,function () { browser.setValue(userNameField,wrongUser); browser.setValue(passwordField,wrongPassword); browser.click('button[value="Login"]'); }); this.When(/^I try to login with the correct credentials$/,c.userName); browser.setValue(passwordField,c.password); console.log('before pressig the button'); browser.click('button[value="Login"]'); console.log('logged in'); }); };
第一次执行时很好.第二个也工作时,我只是没有看到
logged in
在控制台上.两者都在同一个网站上运行,并且都点击了同一个按钮.在第二种情况下,登录成功后,浏览器将重定向到角度SPA.这里的一切都正确加载,但就是这样.回调永远不会发生.
用–debug –log =命令运行测试我看到这是最后一行(在超时之前)
[1;30m[01:30:18]: [0m [0;35mCOMMAND [0mPOST "/wd/hub/session/7c334efe-2417-4184-b43c-082ba4441291/element/11/click"
将日志级别切换为详细,并等待〜5min我收到以下错误:
[chimp][selenium.stderr] 01:36:59.561 DEBUG - Executed: [0560aaa14e4cf874afd72336c19e299b,clickElement {id=0.6384125368203968-3}] [chimp][selenium.stderr] 01:37:02.449 WARN - Exception thrown org.openqa.selenium.TimeoutException: timeout: Timed out receiving message from renderer: 10.000 (Session info: chrome=47.0.2526.73) (Driver info: chromedriver=2.19.346063 (38b35413bd4a486d436a9749e090454bc9ff6708),platform=Mac OS X 10.11.0 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 310.12 seconds Build info: version: '2.47.1',revision: '411b314',time: '2015-07-30 03:03:16' System info: host: '<HOST_NAME>',ip: '<IP_ADDRESS>',os.name: 'Mac OS X',os.arch: 'x86_64',os.version: '10.11',java.version: '1.8.0_20' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false,rotatable=false,mobileEmulationEnabled=false,chrome={userDataDir=/var/folders/nc/3cdxbvwj44j_gk1qj24mbr5w0000gn/T/.org.chromium.Chromium.1n3kHd},takesHeapSnapshot=true,databaseEnabled=false,handlesAlerts=true,hasTouchScreen=false,version=47.0.2526.73,platform=MAC,browserConnectionEnabled=false,nativeEvents=true,acceptSslCerts=true,locationContextEnabled=true,webStorageEnabled=true,browserName=chrome,takesScreenshot=true,javascriptEnabled=true,cssSelectorsEnabled=true}] Session ID: 0560aaa14e4cf874afd72336c19e299b at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:408) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595) at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273) at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:332) at com.sun.proxy.$Proxy3.click(Unknown Source) at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:345) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.openqa.selenium.remote.server.KnownElements$1.invoke(KnownElements.java:64) at com.sun.proxy.$Proxy2.click(Unknown Source) at org.openqa.selenium.remote.server.handler.ClickElement.call(ClickElement.java:30) at org.openqa.selenium.remote.server.handler.ClickElement.call(ClickElement.java:1) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) [chimp][selenium.stderr] 01:37:02.458 WARN - Exception: timeout: Timed out receiving message from renderer: 10.000 (Session info: chrome=47.0.2526.73) (Driver info: chromedriver=2.19.346063 (38b35413bd4a486d436a9749e090454bc9ff6708),cssSelectorsEnabled=true}] Session ID: 0560aaa14e4cf874afd72336c19e299b [chimp][selenium.stderr] 01:37:02.471 DEBUG - Finished: POST /session/e103e58b-7ac9-4c8d-8f65-1f60295231d9/element/11/click
对于要加载的SPA的第一页,要初始化的数据,…(铬停止显示页面正在加载)平均需要3-7秒.超时设置为10秒,所以我想增加它,通过
module.exports = function () { this.BeforeScenario(function () { browser.timeout('script',60 * 1000); browser.timeout('page load',60 * 1000); }); };
但这也没有帮助.知道我能做什么/尝试?
只是为了再次澄清 – 登录页面是一个简单的静态服务器端呈现HTML.用户登录后,会将其重定向到SPA,该SPA基于Angular 1.4.按下具有错误凭据的登录按钮可能会起作用,因为我没有被重定向到SPA,而是返回到登录页面.
所有测试都在Chrome OS中运行,在Mac OS X El Capitan上运行
更新:
现在它工作了一次.之后我注意到,当我重新加载网站时,脚本会继续运行,以防它被卡住.
这里的页面以这种方式工作:
访问/页面并初始化角度
> ui-router路由到#/ defaultroute
>控制器初始化并下载一些初始数据
>新控制器在ng-repeat中初始化并下载更多数据
所以是的,它有相当多的数据下载并等待整个页面显示出来.也许这会给chimp.js或webdriver.io带来麻烦?
当然,从browser.click切换(…); to browser.key([‘Enter’]);也不起作用.卡住和重新加载浏览器的相同问题修复了它.似乎silenium可能没有得到页面实际完成加载.这就是重新加载页面的原因.知道怎么解决这个问题吗?
顺便说一句,我也提出了一个问题:https://github.com/xolvio/chimp/issues/165
更新2:
在Firefox和PhantomJS中它起作用,Safari根本不运行.
也许在这一点上我只想知道错误在哪里,如果它是一个已知的bug,…