我的测试正在......有点...... 问题是,有时这会找到元素,有时它不会。我假设页面加载了一会儿。我需要添加一些等待时间。我不确定如何使用非角度网站
这是有效的部分......约占50%的时间
browser.driver.findElement(By.xpath("//button[.='Log In']")).submit();
这是我试图做的事情
browser.driver.wait(function() {
expect(browser.driver.findElement(By.xpath("//button[.='Log In']"))).isPresent().toBe(true);
});
browser.driver.findElement(By.xpath("//button[.='Log In']")).submit();
这是我得到的堆栈
Using the selenium server at http://localhost:4444/wd/hub
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
WebDriver.sleep(50000)
at [object Object].webdriver.promise.ControlFlow.timeout (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1358:15)
at [object Object].webdriver.WebDriver.sleep (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:600:21)
at [object Object].<anonymous> (/Library/WebServer/Documents/youman/test/spec/craiglist.js:56:24)
at /Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/jasminewd/index.js:94:14
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20)
at [object Object].webdriver.promise.ControlFlow.runEventLoop_ (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8)
at [object Object].wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
F
Failures:
1) Craigslist automation should greet the named user
Message:
timeout: timed out after 10000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 11.073 seconds
1 test, 2 assertions, 1 failure
Asims-MacBook-Air:test asimzaidi$ ./node_modules/.bin/protractor protractor.conf.js
Using the selenium server at http://localhost:4444/wd/hub
F
Failures:
1) Craigslist automation should greet the named user
Message:
Error: expect called with WebElement argument, expected a Promise. Did you mean to use .getText()?
Stacktrace:
Error: expect called with WebElement argument, expected a Promise. Did you mean to use .getText()?
at Error (<anonymous>)
==== async task ====
at [object Object].<anonymous> (/Library/WebServer/Documents/youman/test/spec/mytest.js:56:24)
==== async task ====
Asynchronous test function: it()
Error
at [object Object].<anonymous> (/Library/WebServer/Documents/youman/test/spec/craiglist.js:13:5)
at Object.<anonymous> (/Library/WebServer/Documents/youman/test/spec/mytest.js:10:1)
Finished in 9.707 seconds