Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to doubleclick in selenium webdriver c#

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();

The HTML is

<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>
like image 239
user3198015 Avatar asked Mar 19 '23 06:03

user3198015


1 Answers

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();
like image 78
user3198015 Avatar answered Mar 26 '23 03:03

user3198015