Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Conditional and Looping operations in Selenium Webdriver.

    • 0
    • 5
    • 0
    • 1
    • 1
    • 0
    • 0
    • 0
    • 174
    Comment on it

    These are the Following methods in Selenium are used in conditional and looping operations:-

    1. isEnabled() method is used when you want to verify weather a certain element is enabled or not before executing a command.

       WebElement txtbox-username = driver.findElement(By.id("username"));
       if(txtbox-username.isEnabled()){
        txtbox-username.sendkeys("example");
      }
      

    2.isDisplayed() method is used when you want to verify weather a certain element is displayed or not before executing a command.

         do{
                //do something here
        }while (driver.findElement(By.id("username")).isDisplayed() );
    

    3.isSelected() method is used when you want to verity a certain checkbox,radio button or option in a drop- down box is selected.It doesnot work on other elements:-

       //"one-way" and "two-way" are radio buttons
       if(driver.findElement(By.id("one-way")).isSelected();
       {
        driver.findElement(By.id("two-way")).click();
       }
    

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: