无法在 selenium webdriver c# 中双击 [英] Unable to doubleclick in selenium webdriver c#
问题描述
我正在尝试使用 c# Selenium WebDriver 中的 Actions 类双击选择框中的选项.以下代码适用于 Firefox,但不适用于 IE 或 Chrome.关于为什么或如何调查问题的任何建议?
I'm trying to doubleclick on an option within a selectbox using the Actions class in c# Selenium WebDriver. The following code works fine for firefox but not for IE or Chrome. Any suggestions on why or how I might investigate whats going wrong?
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>
推荐答案
据我所知,双击操作在 IE 或 Chrome 中对选择元素中的选项不起作用.我已更新我的代码以单击选择菜单中的选项,然后双击选择元素本身而不是选项.适用于 FF、IE 和 Chrome.
From what I can tell the doubleclick action does not work in IE or Chrome on an option in a select element. I have updated my code to click the option from the select menu, then doubleclick the select element itself rather than the option. Works for FF, IE and 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();
这篇关于无法在 selenium webdriver c# 中双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!