0

Selenium Webdriver C#- why do I have to click twice to select radio button? Here is the code:

weItem_TypeRadio = _driver.FindElement(By.CssSelector("input[name*='" 
                 + stcItemType 
                 + "'][value='HLP'][type='radio']")
                 , _stcintTimeoutInSeconds);
weItem_TypeRadio.Click(); // first click puts a dotted box around radio button
weItem_TypeRadio.Click(); // this click actually selects the radio button

Webdriver v2.8 Asp.net 4.0 C#

Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52
Remy
  • 407
  • 3
  • 17

2 Answers2

2

In theory, you shouldn't have to click twice. In practice, the IE driver is especially sensitive to window focus, and this can happen if the IE window isn't the foreground, focused window at all times. There is a blog post that discusses how clicks are performed in the IE driver (using so-called "native events") and the ramifications of using them.

JimEvans
  • 27,201
  • 7
  • 83
  • 108
0

Code for Selecting Radio Button using Java in Selenium WebDriver,

I tried clicking the Radio button in IE browser which is inside the table span, hardly i found the solution finally with double statement of Click as IE driver very sensitive to window, it gives 'dot' at first around the Radio button with First Click statement and it got selected successfully with the same statement (Click) again.

WebDriver WD1;
WD1.findElement(By.id("singles_out_tickets")).click();
WD1.findElement(By.id("singles_out_tickets")).click();