问题
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