Author: <span>Aditya</span>

How to use WebDriver to handle dropdown or select tag

We can use regular webdriver command to handle most of webelements like check box, text box etc. but to handle dropdown or select element as given below [sourcecode language=”htm”] <select id="sel123"> <option value="my">My</option> <option value="name">Name</option> <option value="is">Is</option> <option value="admin">Admin</option> </select> [/sourcecode] you can use following code. [sourcecode language=”csharp”] IWebElement sTag = driver.FindElement(By.Id("sel123")); OpenQA.Selenium.Support.UI.SelectElement selectTag = new OpenQA.Selenium.Support.UI.SelectElement(sTag); selectTag.SelectByValue("admin"); //Or selectTag.SelectByText("Admin"); //Or selectTag.SelectByIndex(3); [/sourcecode] In case if you want to verify how many options are available in select tag then use following: [sourcecode language=”csharp”] var availableOptions = selectTag.Options; foreach (IWebElement item in availableOptions) { Console.WriteLine(item.Text); } [/sourcecode]

Selenium GRID and Nunit

Everyone asking about how to setup Selenium GRID. We were using Visual Studio to execute script which was kind of time consuming. It used to take minium 1.5 hours after every build. After that I implemented GRID and divided  tests into groups based on category and ran in parallel and achieved 66% improvement. Not bad ;). [gview file=”http://learnseleniumtesting.com/wp-content/uploads/2012/10/SeleniumGrid_LearnSeleniumTesting1.pdf”] If you have any question, I will try to answer. If you are using webdriver and want to use grid then you need to use remote webdriver instead. Every thing will be the same. Remember: If you try to use two instances …

Mouse hover and other mouse events in WebDriver

This is widely known issue among web driver community, how to perform mouse hover.  I have many scenarios in my test where I needed to perform mouse hover to see calendar, email schedule etc. After many attempts, I found solution which is actually working very well for me but I am not sure if it’s going to work with your application of not.  Before going into coding we need to consider few limitations, In Firefox, you have to maximize the webpage just before doing mouseover to get the focus on browser. Works fine even in normal window size with other …