admin管理员组文章数量:1426058
A page I am testing has a button that takes you to a different page on the same site. After clicking on that button, I want to wait for that page to load before continuing. Normally, I would just wait for some element on that page to load, but since I recently updated nightwatch/selenium, that waitForElementPresent() test has stopped working. In the process of debugging the problem, I thought it made sense to wait for the new URL to load, but I don't see a nightwatch way to do that. I can hard code a wait with a pause() followed by an assert.urlContains(), but there's got to be a better way. Any suggestions?
What used to work:
this.waitForElementVisible(runCSS,3000)
.click(runCSS)
.waitForElementPresent(newPageElementCSS,5000)
but now it times out on the second wait, even though I can clearly see the new page on the browser display (Firefox 45.0.1 on Windows 8.1).
A page I am testing has a button that takes you to a different page on the same site. After clicking on that button, I want to wait for that page to load before continuing. Normally, I would just wait for some element on that page to load, but since I recently updated nightwatch/selenium, that waitForElementPresent() test has stopped working. In the process of debugging the problem, I thought it made sense to wait for the new URL to load, but I don't see a nightwatch way to do that. I can hard code a wait with a pause() followed by an assert.urlContains(), but there's got to be a better way. Any suggestions?
What used to work:
this.waitForElementVisible(runCSS,3000)
.click(runCSS)
.waitForElementPresent(newPageElementCSS,5000)
but now it times out on the second wait, even though I can clearly see the new page on the browser display (Firefox 45.0.1 on Windows 8.1).
Share Improve this question edited Apr 4, 2016 at 17:35 Bryn Wolfe asked Apr 4, 2016 at 15:35 Bryn WolfeBryn Wolfe 1831 gold badge1 silver badge14 bronze badges 1- if the tests don't work as they used to after the update, maybe try to update the selenium-server-standalone to the latest too? there were some patibility issues with older versions and latest mozilla. – anasarbescu Commented Apr 10, 2016 at 0:28
2 Answers
Reset to default 1Wait for something (a selector) that is unique to the page that will be loaded after the click. It can be anything as long as it doesn't exist on the current page.
For example,
This would wait for <div name="Thingy">
anywhere on the page:
client.waitForElementVisible('div[name="Thingy"]',3000)
I guess, in Nightwatch.js, wait for the page to load can be achieved using 'body' element of the DOM. Suppose, if we want to wait the page for 1 second. we will achieve it using the mand .waitForElementVisible('body', 1000)
. The second parameter is measured in ms.
本文标签: javascriptWhat is the proper way to wait for a new URL to load in nightwatchStack Overflow
版权声明:本文标题:javascript - What is the proper way to wait for a new URL to load in nightwatch? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745439589a2658384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论