Selenium waitforpopup

我与影子孤独终老i 提交于 2019-12-10 11:42:35

问题


How to stop the selenium server until a popup opens?

We have selenium.waitForPageToLoad to stop the server until the Page Loads. But is there any way to stop it for Popup?

I tried it with selenium.WaitForPopup, but I can't find popup id. Because I created a popup box with div element(whose id is popup_container).

And I tried the following code:

selenium.WaitForPopUp("id=popup_container", "30000");

But that doesn't work. Any help?


回答1:


Your 'popup' is not actually a popup, it's just a div tag. So you want to wait until that element (div tag) is present. There is a method to check if the element is present:

selenium.IsElementPresent(div_of_the_popup)

You can loop checking until the element is present or a certain time expires. You can see sample loops at this other question/answer.

The later versions of Selenium, do include methods for doing the wait for element. Ultimately, the key to your problem is waiting for the DIV not a popup.

UPDATE: Based on your other posts, it looks like you are using Selenium-Webdriver. If so, then you can use the example from the selenium web page for explicit waits




回答2:


C#

Your popup is actually a div. You can do it like this:

Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Id("Popup_Div_Id")));


来源:https://stackoverflow.com/questions/9990793/selenium-waitforpopup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!