Tuesday, 4 August 2015

How to check whether the selectbox is singleListbox or multipleListBox.


Script Code-

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MultipleListBox {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("C:\\selenium\\Selenium_web.html"); 
/*here the url is my personal page, you can try for any url which has such scenario or you can develop your own html page having the above html code.*/
        System.out.println(driver.findElement(By.xpath("//select[@id='mdd']")).getAttribute("multiple")); // this will print true, which means it is multipleListBox
        System.out.println(driver.findElement(By.xpath("//select[@id='sdd']")).getAttribute("multiple"));//

// this will print null, which means it is singleListBox       
    }
}

No comments:

Post a Comment

Angular JS Protractor Installation process - Tutorial Part 1

                     Protractor, formally known as E2E testing framework, is an open source functional automation framework designed spe...