Selenium Webdriver C#为什么我必须单击两次才能选择单选按钮
Selenium Webdriver C#-为什么我必须单击两次才能选择单选按钮? 代码如下:Selenium Webdriver C#为什么我必须单击两次才能选择单选按钮,c#,selenium,webdriver,jradiobutton,C#,Selenium,Webdriver,Jradiobutton,Selenium Webdriver C#-为什么我必须单击两次才能选择单选按钮? 代码如下: weItem_TypeRadio = _driver.FindElement(By.CssSelector("input[name*='" + stcItemType + "'][value='HLP'][type='radio']") , _stcintTimeoutInSeconds); we
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#理论上,您不应该单击两次。实际上,IE驱动程序对窗口焦点特别敏感,如果IE窗口不是始终处于前景的聚焦窗口,则可能发生这种情况。有一篇文章讨论了IE驱动程序中如何执行点击(使用所谓的“本机事件”)以及使用它们的后果。在Selenium WebDriver中使用Java选择单选按钮的代码 我试着点击IE浏览器中位于表格范围内的单选按钮,但我几乎没有找到解决方案,最终使用双击语句,因为IE驱动程序对窗口非常敏感,它首先在单选按钮周围使用first Click语句给出“点”,然后再次使用相同的语句(单击)成功选中它
WebDriver WD1;
WD1.findElement(By.id("singles_out_tickets")).click();
WD1.findElement(By.id("singles_out_tickets")).click();