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 |
Mention what if you do not specify anything when you call a procedure?
In the Web page we have a table link, if we click on that link all the contents under that link will be sorted (asscending/Descending). Now i want to check in which order the list is ? for that i need to get the data in to some var How can i get that cells data?
How can you create a file object to work with the files in the vbscript language?
Could Anybody tell me the VBscript for REVERSE an Integer int reverse(int num) Ex:246 to 642
who you define variables and functions in VB?
What is the extension of the vbscript file?
what is test scenario?
How to write functional test cases for send button in gmail.
Which is the default Data types in VBScript?
write a program to display the system specifications of client system with the help of vb script.
Hi everybady, i have faced few Qns in one of i attended interview, please help me out with these below Qns. 1. how to join values without using join function? 2. how to compare values without using String compare function? 3. input is Bangalore, but i need output like this below format, what is function to use and get this outcome B A N G A L o R E 4. Input is "CapGemini" but uotput should be like this "inimeGpaC" 5. Input is 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Can someone let me know results of this Qns, please. Thanks.
How to find a latest file from any folder