不,但真的!我知道这个通用问题已被问过数千次,但有一些更具体的问题对我来说似乎可行,因此我想知道如何实现它
我正在使用
对
如果不完全相同,但我如何让量角器挂起,直到页面完全加载
显然,我可以做很多肮脏的解决方案,比如显式等待.但是我每隔一段时间就会回到这个问题,所以我对这些 70% 的时间都针对特定原因有效的肮脏解决方案不感兴趣
附:我认为该按钮会更改 document.load()
事件.但是我不知道我应该在控制台中写什么,以便在我刷新页面时该脚本记录一条消息
你试过了吗
await browser.wait(async() =>等待 browser.driver.executeScript('return document.readyState;') === 'loading', 2000).then(() => true, () => true);等待 browser.wait(async () =>await browser.driver.executeScript('return document.readyState;') === '完成', 5000)
No, but really! I know this generic question has been asked thousands of times, but there is something more specific that looks feasible to me and thus I want to know how to achieve it
I'm testing an angular app with protractor. Inside the app I want to verify that when I click a link I'm being redirected to the right page (non-angular). The problem is that until I reach the page I'm verifying, the url changes 3 times or so (there are multiple redirections happening), so I can't make a waiting function wait until the page is loaded completely
browser.sleep()
for more than 1000 ms!browser.waitForAngular()
as this is not an angular pageExpectedConditions.urlIs()
the url is the variable I'm assertingExpectedConditions.presenseOf()
the page maybe changing so I can't rely on elements insidebrowser.executeScript("return window.document.readyState")
returns compete
immediately, though the page is still loading (I was certain this is what I need, but that didn't work either)innerHtml
of the whole page not change for at least 3 sec, but it fails because at times there is a pause of more than 3 sec between redirects are happening. Everything above 3 sec isn't a reasonable timeout
What I noticed is when the browser is loading the page, Reload this page
button changes its state to Stop loading this page
(X icon) until I'm redirected to the final page (screenshots below). So the question is is there a way to make protractor point to the same condition that chrome uses to choose which icon is displayed?
vs
And if not exactly the same, but how do I make protractor hang until the page is fully loaded
Obviously there are a lot of dirty solutions that I can do like explicit waits. But I'm coming back to this question every once in a while, so I'm not interested in these dirty solutions that work 70% of the time for a specific cause
P.S. I figured that the button changes the icon on document.load()
event. But I can't figure out what should I write in the console in order for that script to log a message when I refresh they page
Have you tried
await browser.wait(async () =>
await browser.driver.executeScript('return document.readyState;') === 'loading', 2000)
.then(() => true, () => true);
await browser.wait(async () =>
await browser.driver.executeScript('return document.readyState;') === 'complete', 5000)
这篇关于如何使量角器中的自动化测试脚本等待,直到页面完全加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!