Monday, 30 January 2012

Dropdown box in selenium web driver in .net

To set the desired value into Dropdown box, the below piece of would work fine!
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
//add this name space to access WebDriverWait
using OpenQA.Selenium.Support.UI;
namespace AutomationUsingSelenium
    class Program
        public static InternetExplorerDriver WebDriver;
        static void Main(string[] args)
        var capabilitiesInternet = new OpenQA.Selenium.Remote.DesiredCapabilities();
        capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true);
        WebDriver = new InternetExplorerDriver(capabilitiesInternet);

 //Get the hold of the dropdown box by Name
 IWebElement setValueConvert = WebDriver.FindElement(By.Name("from"));
//Place the drop down into selectElemnet
 SelectElement clickThisitem=new SelectElement(setValueConvert);
//Select the Item from dropdown by Index
//Select the Item from dropdown by Text


Wesite Under Test:
Md. Jawed

No comments:

Post a Comment