Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法在selenium webdriver c中双击_C#_Selenium_Selenium Webdriver_Action_Double Click - Fatal编程技术网

C# 无法在selenium webdriver c中双击

C# 无法在selenium webdriver c中双击,c#,selenium,selenium-webdriver,action,double-click,C#,Selenium,Selenium Webdriver,Action,Double Click,我试图使用c Selenium WebDriver中的Actions类双击selectbox中的一个选项。以下代码适用于firefox,但不适用于IE或Chrome。关于我为什么或如何调查出了什么问题,有什么建议吗 var sideBarAgentList = new SelectElement(driver.FindElement(By.CssSelector("#agentSelectBox"))); var agentInList = sideBarAgentList.Options.Fi

我试图使用c Selenium WebDriver中的Actions类双击selectbox中的一个选项。以下代码适用于firefox,但不适用于IE或Chrome。关于我为什么或如何调查出了什么问题,有什么建议吗

var sideBarAgentList = new SelectElement(driver.FindElement(By.CssSelector("#agentSelectBox")));
var agentInList = sideBarAgentList.Options.First(o => o.Text == "Agent49159 - 49159");
new Actions(driver).DoubleClick(agentInList).Perform();
HTML是

<select id="agentSelectBox" ondblclick="javascript:addAgentDesktop(this.selectedIndex);" onchange="javascript:showAgentInfo(this.selectedIndex);" style="width:220px;background:#e0e0e0;font-family:Verdana;font-size:75%;" size="22">

  <option value="0" style="background:white;color:blue">

      Agent49159 - 49159

  </option>

</select>
尝试更改此行:新建操作驱动程序。双击代理列表。执行


至:新建操作驱动程序.DoubleClickagentInList.build.Perform

据我所知,双击操作在IE或Chrome中对选择元素的选项不起作用。我已更新代码,从“选择”菜单中单击该选项,然后双击“选择”元素本身而不是该选项。适用于FF、IE和Chrome

new SelectElement(driver.FindElement(By.CssSelector("#agentSelectBox"))).Options.First(o => o.Text == "Agent49159 - 49159").Click();;       
new Actions(driver).DoubleClick(driver.FindElement(By.CssSelector("#agentSelectBox"))).Perform();

和用户3198015一样,我发现Selenium的双击操作在Firefox中有效,但在Chrome中无效。解决方法是使用两次单击事件,如我对的回答中所示。

您确定这不是等待问题吗?您好,这似乎没有任何效果。双击继续在FF中工作,但不在Chrome或IE中工作。我现在已经找到了一个适用于所有3个版本的解决方案,那么您是否将Chrome和IE驱动程序添加到您的项目中了?!