lundi 24 août 2015

Selenium webdriver: if condition for a long list of objects

Is there a way I can simplify the code below?

public static void InputData(){
 //Lastname
 if (driver.findElements(By.id("last_name")).size() != 0) {  
 driver.findElement(By.id("last_name")).sendKeys("MARSUPIAL");
 } 
 //Fistname
 if (driver.findElements(By.id("first_name")).size() != 0) {  
 driver.findElement(By.id("first_name")).sendKeys("MARK"); 
 } 

}

I have 20 items with the same 'if' scenario

instead of doing "if object exist write 'x'" per text box is there a way to write it in a single if statement?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire