Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the properties of regexp object?

1028


Explain the asc function?

874


1. How do declare public variable in vb scripts?

2039


Explain about adodb.stream class?

1041


what is the difference between modular and data and keyword driven framework

2193


How can you create a file object to work with the files in the vbscript language?

902


What is the difference between function and procedure?

1138


How to delete a cookie using vbscript?

1083


What is the difference between for loop and while loop?

1000


Hi All, I am facing one problem in QTP. There is link object in my application that exist in the Frame in mozilla firefox. Click event on that object is not working but once the frame is enabled/activated then click event works fine.But the frame does not have the activate property. This problem is coming in firefox only. Regards

2650


can anyone tell me the procedure of interview held in applabs

2133


how to increasing the numbers in a given text box please write a vb script

2152


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.

1804


What are the rules to name variable in vbscript?

1017


How to open a file. What is the perpose of true and false mode there?

1056