power_settings_new
How may I declare a test step(not a test case) as optional in Selenium Webdriver and TestNG when using Page Object Model?
by (171 points)
Can you give me your sample code?
by
moved by
@Test
 public void verifyValidLogin()
 {
  WebDriver driver = new FirefoxDriver();
  driver.manage().window().maximize();
  driver.get("http://evergreen.fruit.tips");
  
  MenuPage menu = new MenuPage(driver);
  
  menu.clickCloseModalButton();  //I want this step to be optional
  
  menu.clickMenuButton();  

}
by (171 points)
How do you want this step to be optional? Do you want it to be optional if Model is not present?
by (391 points)
I have the test to continue to run even if the Modal does not come up after certain time?
by (171 points)
Can you post your code of menu.clickCloseModalButton?
by (391 points)
public void clickCloseModalButton()
    {

        driver.findElement(closeModalButton).click();
    }

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes

Okay, your closeModelButton should look something like this.

 

public void clickCloseModalButton()
{

WebDriverWait wait = new WebDriverWait(driver, 25); // choose your time  to wait for model dialog here

wait.until(ExpectedConditions.visibilityOfElementLocated(closeModalButton));

if(driver.findElement(closeModalButton).isVisible()){//This will make it optional. 

driver.findElement(closeModalButton).click();

}

}

add
...