Note- use the method getAttribute("multiple") , if it return 'true' then it is multipleListBox else if return null then it is singleListBox.
Sample html code-
<select id="sdd"> //in this select box only one option can be selected
Sample html code-
<select id="sdd"> //in this select box only one option can be selected
<option>idly</option>
<option>dosa</option>
<option>vada</option>
<option>tea</option>
</select>
<br>
Combo
<select id="mdd" multiple> //in this select box only multiple option can be selected
<option>idly</option>
<option>dosa</option>
<option>vada</option>
<option>tea</option>
</select>
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