Arun
Arun

Reputation: 738

How to click the DOM element in selenium webdriver thru C#

I m doing the website automation thru Selenium webdriver in Firefox. Everything is fine but I dont know how to click the radio button.

There are two radio buttons in the web (i) Family Information and (ii) Individual Information. Target information obtained in the Selenium IDE. (i) name=indFamily (ii) document.pebPostLogin.indFamily[1]

I can easily click the first one Family information thru following code:

driver.FindElement(By.Name("indFamily")).Click();

But dont know the C# command for the second one "Individual Information". I have recorded the actions in Selenium IDE in Firefox and exported into C# file but DOM commands are not exported in C#. Following error message seen in C# file.

// ERROR: Caught exception [Error: Dom locators are not implemented yet!]

Please find below the source code identified thru Firebug.

<input name="indFamily" tabIndex="6" onkeypress="submitOnEnter(window.event.keyCode, document.pebPostLogin)" type="radio" value="Family"/>
<input name="indFamily" tabIndex="7" onkeypress="submitOnEnter(window.event.keyCode, document.pebPostLogin)" type="radio" value="Individual"/>

Please help me out...

Upvotes: 2

Views: 10862

Answers (2)

user4418732
user4418732

Reputation: 11

Try following code:

driver.FindElement(By.XPath("//input[@name='xxxx' and @value='xx']")).Click();

xxxx = element name

xx = value (for eg., yes)

Upvotes: 1

Arun
Arun

Reputation: 738

It has been fixed using Xpath. The code is below:

driver.FindElement(By.XPath("//input[@value='Individual']")).Click();

Thanks to Alexander and http://www.w3schools.com/xpath/xpath_syntax.asp

Upvotes: 1

Related Questions