Difference between Waitforpopup and Expected condition wait

Answered

Hi guys

I was doing some automation where operation should be performed when pop up is present
I worte this line

 


WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.alertIsPresent());

while on the other hand one of my collegue did the same with just writing
waitforopopup();  a static metheod is created  without body when we use this

Now i am not sure that either i am right or he is…..
which one to use ..?

Vice Professor Asked on August 19, 2014 in Selenium WebDriver.
Add Comment
  • 4 Answer(s)
    Best answer

    Hi Ankit,

    Sorry for the late reply Ankit,

    WaitForPopUp() has nothing inside it. This call will do nothing.

    I think what your friend wanted to do was to put an implementation of WaitForPopup() call similar to what we have in webdriver backed selenium. This API in webDriverBackedSelenium is to wait for a javaScript window for a specified time.

    Thanks
    Virender

    Professor Answered on August 23, 2014.
    Add Comment

    Hi Ankit,

    It depends on what the waitforpopup() methods does. Can you paste the code of waitforpopup() method?

    Thanks
    Virender

    Professor Answered on August 19, 2014.
    Add Comment

    hi virendar thanx for your reply and here is the code

    package testv;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.internal.seleniumemulation.WaitForCondition;
    import org.openqa.selenium.support.ui.WebDriverWait;

    public class testpopup{
    public static void main(String arg[]) throws Exception {
    // WebDriver driver;

    WebDriver driver = new FirefoxDriver();
    driver.get(“http://demo.cropin.in/application/login/Login.aspx”);
    Thread.sleep(3000);

    String message = “”;
    driver.findElement(By.xpath(“//input[@name=’txtUserName’]”)).sendKeys(
    “amit”);
    driver.findElement(By.xpath(“//input[@name=’txtPassword’]”)).sendKeys(
    “12345”);
    driver.findElement(By.xpath(“//input[@name=’btnSignIn’]”)).click();
    System.out.println(“Its come before thread sleep”);
    // Thread.sleep(8000);

    WaitForPopup();

    System.out.println(“Its come after thread sleep”);
    message = driver.switchTo().alert().getText();
    driver.switchTo().alert().accept();
    System.out.println(“value of mess” + message);

    driver.quit();

    }

    private static void WaitForPopup()
    {
    // TODO Auto-generated method stub

    }

    }

    Vice Professor Answered on August 19, 2014.
    Add Comment

    hi virendar

    i am still a little confused
    it fulfilled the motive i mean we wanted to wait for that pop up only
    will  this method fails in some case..?
    if i am right or he is..?

    Vice Professor Answered on August 23, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.