Skip to main content
selenium tag is associate with v1, not webdriver
Link
ECiurleo
  • 2k
  • 1
  • 16
  • 45
added 88 characters in body
Source Link
Elsid
  • 43
  • 1
  • 2
  • 7

I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.

Thanks

if (!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
} else if(!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
}

What I want to happen is:

If Element 1 is not selected

Click it

Else Click Element 2

I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.

Thanks

if (!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
} else if(!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
}

I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.

Thanks

if (!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
} else if(!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
}

What I want to happen is:

If Element 1 is not selected

Click it

Else Click Element 2

I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.

Thanks

     if ( !driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() )
             
              {
                      driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
                  }
              
              
              else if( !driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() )
                     
              {
                      driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
                  }

I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.

Thanks

     if ( !driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() )
             
              {
                      driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
                  }
              
              
              else if( !driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() )
                     
              {
                      driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
                  }

I have this code below which seems to not go to the else if statement. It runs the first part but never seems to go to part 2, if element 1 is already selected.

Thanks

if (!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[1]")).click();
} else if(!driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).isSelected() ) {
    driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[1]/div/div/div[2]/div/div[1]/div[1]/div[2]/div[2]/span/span[2]")).click();
}
Source Link
Elsid
  • 43
  • 1
  • 2
  • 7
Loading