In my before post, We accept seen event of HOW TO SELECT OPTION BY VISIBLE TEXT from drib down. There are 2 to a greater extent than alternatives to select alternative value from drib down or listing box inward selenium webdriver software testing tool. 1. Selecting Option By Value in addition to 2. Selecting Option By Index. You tin role whatever 1 from these three to guide value from listing box of your software spider web application page. If y'all know, nosotros tin role "select" ascendance or "addSelection" ascendance inward selenium IDE software testing tool to guide alternative from listing box.
First of all allow me demo y'all deviation betwixt visible text, value in addition to index of listing box option. Bellow given ikon volition demo y'all clear deviation betwixt value, visible text in addition to index.
1. Select Option By Value In WebDriver
Syntax for selecting alternative yesteryear value inward webdriver is equally bellow. First syntax volition locate the guide chemical part from page of software spider web application in addition to s syntax volition guide the alternative from guide box yesteryear value = Italy.
Select listbox = novel Select(driver.findElement(By.xpath("//select[@name='FromLB']"))); listbox.selectByValue("Italy");
2. Select Option By Index In WebDriver
Syntax for alternative option yesteryear index from listing box is equally bellow. It volition guide 1st element(index = 0) from guide box of software spider web application page.
Select listbox = novel Select(driver.findElement(By.xpath("//select[@name='FromLB']"))); listbox.selectByIndex(0);
Execute bellow given event inward your eclipse in addition to verify result. Try to role it inward dissimilar applications.
@Test populace void exam () throws InterruptedException { driver.findElement(By.id("text1")).sendKeys("My First Name"); //Selecting value from drib downward yesteryear value Select listbox = novel Select(driver.findElement(By.xpath("//select[@name='FromLB']"))); listbox.selectByValue("Italy"); listbox.selectByValue("Mexico"); listbox.selectByValue("Spain"); driver.findElement(By.xpath("//input[@value='->']")).click(); WebDriverWait await = novel WebDriverWait(driver, 15); wait.until(ExpectedConditions.elementToBeClickable(By.id("text2"))); //Selecting value from drib downward yesteryear index listbox.selectByIndex(0); listbox.selectByIndex(3); driver.findElement(By.xpath("//input[@value='->']")).click(); Thread.sleep(2000); }