user3198015
user3198015

Reputation: 121

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>

Upvotes: 4

Views: 15464

Answers (3)

Steve Saporta
Steve Saporta

Reputation: 4881

Like user3198015, I have found that Selenium's doubleclick action works in Firefox but not Chrome. A workaround is to use two click events, as shown in my answer to this related question.

Upvotes: 0

user3198015
user3198015

Reputation: 121

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

Upvotes: 7

Nael Marwan
Nael Marwan

Reputation: 1038

Try to change this row: new Actions(driver).DoubleClick(agentInList).Perform();

to: new Actions(driver).DoubleClick(agentInList).build().Perform();

Upvotes: 1

Related Questions