1

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...

4

2 回答 2

1

它已使用 Xpath 修复。代码如下:

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

感谢亚历山大和http://www.w3schools.com/xpath/xpath_syntax.asp

于 2013-07-12T14:34:25.417 回答
1

试试下面的代码:

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

xxxx = element name

xx = value (for eg., yes)
于 2015-01-05T03:46:26.447 回答