How to select a value from a list box by using Selenium
web-driver?
Answers were Sorted based on User's Feedback
Answer / mahendra
public static void m1()
{//intantiate webdriver
WebDriver driver = new FirefoxDriver();
//open the browser
driver.get("http://www.lanoie.net/classes/XHTML/forms/lectures/lecture8_1.html");
//frist get the webelement of select tag
WebElement sele=
driver.findElement(By.xpath("//html/body/div/div[1]/div/form[3]/p[1]/select"));
//instantiate select class with that webelement
Select select=new Select(sele);
//get all value into list
//select.selectByValue("Modem 33.6 Kbps");
select.selectByVisibleText("Modem 33.6 Kbps");
select.selectByIndex(4);
WebElement
selectm=driver.findElement(By.xpath("html/body/div/div[1]/div/form[2]/p/select"));
Select selet = new Select(selectm);
//selet.selectByIndex(3);Or
//selet.selectByVisibleText("Netscape 4");or
//selet.selectByValue(“mahendra”)or
List<WebElement> options=select.getOptions();
for(WebElement option : options)
{if (option.getText().equals("T-1"))
{
option.click();
}
}
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / elite
We need to get all options using String[] options = Selenium.getSelectOptions
and use selenium.select(options[2]) which will select second option
| Is This Answer Correct ? | 1 Yes | 3 No |
how to store charecters of HARIBABU Using arrays
Can any 1 modify the code whr in want to add\rename a excel sheet in qtp?
Difference between Do while loop and while wend loop
Hi I don't have any idea on VBscript. can any one point me to a good web site to learn VBscript. Regards lina
write a vb script to add two 2*2 matrix
How to copy from one script to another script in qtp
When does ‘on click of button’ event gets triggered in the vbscript language?
How will you convert a string to lower case string using vbscript?
how to increase the values in text box in a given text box increament by two values by clicking on button
PLz send me the VB scripts which is having more examples my email id : hareen_11@yahoo.com
Explain different types of segment?
which is the good software training centre in bangalore?