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 |
Is vbscript a case-sensitive or case-insensitive?
HI how can handle dynamic image through vb script example we have to create email id fill the edit box(these latters change wrong password) i am wating your answer
HOw we can apply web service checkpoint in QTP 9.5? I tried it out with net connection also. But not getting success.
Give me sm ideas to write Vbscripts abt protocol testing abilash700@gmail.com.
Write a function for Instr(). We need to write a function that works as same as Instr(). Code or Even pseudo code is good enough for me.?
How will you get a combined string from array of string in vbscript?
Write a VB Script to count blank Lines in a notepad
How will you convert a given number to long in vbscript?
Explain How do you create a recordset object in vbscript?
How to Import data from a file (file is on the desktop) to the data table
Hi all..I have two values. a=20 ,b=30 I want to perform c= a+b and c= a*b using user define function.please anyone give the answer
What are the properties of regexp object?