Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

javascript - 等待新的URL在守夜中加载的正确方法是什么?(What is the proper way to wait for a new URL to load in nightwatch?)

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.

(通常,我只是等待该页面上的某些元素加载,但是由于我最近更新了守夜/硒,因此waitForElementPresent()测试已停止工作。)

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.

(在调试问题的过程中,我认为等待新URL加载是很有意义的,但是我看不到有守夜的方法。)

I can hard code a wait with a pause() followed by an assert.urlContains(), but there's got to be a better way.

(我可以在pause()后加上assert.urlContains()来硬编码等待,但是必须有一种更好的方法。)

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).

(但是现在,即使我可以在浏览器显示屏上清楚地看到新页面(Windows 8.1上的Firefox 45.0.1),它也会在第二次等待时超时。)

  ask by Bryn Wolfe translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Wait 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:

(这将等待页面上任何地方的<div name="Thingy"> :)

client.waitForElementVisible('div[name="Thingy"]',3000)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...