We can see if the radiobutton is selected or not using Selected
property as illustrated in the below example.
We have to use Selected property. This property returns true if the radio button is selected else it returns false.
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com
We have to use Selected property. This property returns true if the radio button is selected else it returns false.
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading;
using
OpenQA.Selenium;
using
OpenQA.Selenium.Firefox;
using
OpenQA.Selenium.Chrome;
using
OpenQA.Selenium.IE;
using
OpenQA.Selenium.Support.UI;
using
System.Collections.ObjectModel;
namespace Abc
{
class Program
{
static void Main(string[]
args)
{
//IWebDriver
x = new InternetExplorerDriver(@"F:\selenium\csharp");
//IWebDriver
x = new FirefoxDriver();
IWebDriver
driver=null;
try
{
driver = new ChromeDriver(@"F:\selenium\csharp");
driver.Url = "http://register.rediff.com/register/register.php";
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50));
driver.Manage().Window.Maximize();
driver.Navigate();
IWebElement
e=null;
Thread.Sleep(5000);
ReadOnlyCollection <IWebElement> ec = driver.FindElements(By.Name("gender"));
for (int
k=0;k<ec.Count;k++)
Console.WriteLine("is gender selected ?" + ec[k].Selected);
Console.ReadLine();
}
catch(Exception e){
Console.WriteLine("Exception ...*****" + e.ToString());
}
finally{
Thread.Sleep(2000);
driver.Quit();
Console.ReadLine();
}
}
}
}
No comments:
Post a Comment