How to select a value from a list box by using Selenium
web-driver?
Answer Posted / 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 |
Post New Answer View All Answers
How to use QTP Object in .vbs(vbscript file) file Ex: Browser().., wait(), exist() and etc...
In what way program "hello world" you can write in vbscript?
Can someone please tell me what poor design in a relational database (not the layout or style) is and how it can be avoided? PLEASE...im desperate.
Could Anybody Please tell me What is the script for Find 3rd Largest element in the Array without using a SORT function int Find(int arr[], int size); Thanks in Advance..
Explain about the extension .hta?
When does ‘on click of button’ event gets triggered in the vbscript language?
How to access array data?
Which in-built function related to an array joins substrings into one string in the vbscript language?
where can i learn VB scripint ?
How will you release the memory acquired by an array variable in vbscript?
How to pass argument by reference to a function in vbscript?
hi all, i had a question, that how to find out hiding a coloumn in a table i had a table having the following column names NAME DESCRIPTION CREATED TIME CREATED USER if i right clicked on a NAME column it will displays a menu having the same column names in a list like NAME DESCRIPTION CREATED TIME CREATED USER with check boxes.if i unched any check box, that column name should not be appear in the main table column names could anyone please solve this problem?
1. How do declare public variable in vb scripts?
what is the features of visual basic?
What is the use of the recordset object and which statement is used to create such an object?