mardi 11 août 2015

How to use If else statements in selenium webdriver using java?

  1. Question:

I have 8 buttons like (discover,news,people,videos,sport,tech,offbeat,ents). so i want to click on any one or more buttons. actually i don't know what to use here, i was thinking if else will work. need some help. Here there is a problem which i feel is, all buttons have same class name so how to use if else for this type of issue.

if(!driver.findElement(By.className("default button ")).isSelected())
    {
      driver.findElement(By.className("default button")).sendKeys("discover");
    }
    else 
    {
        driver.findElement(By.className("default button")).sendKeys("news");
    }

  1. Question:

I have 8 tags as drop downs like (discover,news,people,videos,sport,tech,offbeat,ents). so i want to select only any one tag. how do i use if else statements for this...

thanks in advance !!

Aucun commentaire:

Enregistrer un commentaire