Selenium 2.0 WebDriver Advacanced Interactions DoubleClick Help (C #)

So, as part of my regression tests of selenium, I tried to double-click on the calendar to create a new app. I tried using doubleClick (); method in the advanceduserinteractions library, but there is a problem; two clicks are not fast enough / close enough to trigger the actual double click! Has anyone found a way to handle this while testing them?

+6
source share
6 answers

This code works for me!

Actions action = new Actions(driver); action.doubleClick(myElemment); action.perform(); 
+18
source

Here is the Java equivalent. This code will blindly open the first event. You can add some logic to open a specific event, etc. This code works! (verified using 2.12)

 List<WebElement> events = driver.findElements(By.cssSelector("div.dv-appointment")); for(WebElement event:events){ WebElement body = event.findElement(By.cssSelector("div.body")); if(!body.getText().isEmpty()) //or open a known event { System.out.println(body.getText()); //open the first event Actions builder = new Actions(driver); Action doubleClick = builder.doubleClick(event) .build(); doubleClick.perform(); break; } } 
+2
source

Remember to use

 using OpenQA.Selenium; using OpenQA.Selenium.Interactions; using OpenQA.Selenium.Interactions.Internal; using OpenQA.Selenium.Support.UI; //create Actions object Actions builder = new Actions(driver); //create a chain of actions builder.DoubleClick().Build().Perform(); 

http://selenium-interview-questions.blogspot.ru/2014/03/how-to-double-click-on-web-element.html

+2
source

I also had a problem when Selenium doubleclick event works in Firefox but has no effect in Chrome. Upgrading to Selena did not help; I already have the latest version. (My environment is Ubuntu 14.04, Python 2.7.6, Selenium 2.44.0, Firefox 35.0, Chrome 40.0.2214.91.)

I am not sure why the CBRRacer answer was omitted. I successfully worked on the problem using two click events. This works in both Firefox and Chrome. There are two ways to do this, and both worked for me.

First way:

 elem = driver.find_element_by_css_selector('#myElement') elem.click() elem.click() 

The second way:

 elem = driver.find_element_by_css_selector('#myElement') actions = webdriver.ActionChains(driver) actions.click(elem).click(elem).perform() 
+1
source

I really like the approach used here, in particular, in the order of actions, and then execution, since this allows the reapplication of the actionchain.

http://selenium-python.readthedocs.org/en/latest/api.html#selenium.webdriver.common.action_chains.ActionChains

From the above sample documentation:

 menu = driver.find_element_by_css_selector(".nav") hidden_submenu = driver.find_element_by_css_selector(".nav #submenu1") actions = ActionChains(driver) actions.move_to_element(menu) actions.click(hidden_submenu) actions.perform() 
+1
source

Have you tried to catch an IWebElement and then double-click it?

 IWebElement element = driver.FindElement(By.Id("yourID")); element.Click(); element.Click(); 

I don’t know if this will provide you any functionality or not, but I know that when I execute the click event like the above, it runs as close as possible to double-clicking from the actual user.

Another option is to reference ThoughtWorks.Selenium.Core , however the only drawback to this is that I'm not sure if it works well with the current IWebDriver . It seems to me that he needs to create an instance of IWebDriver .

0
source

Source: https://habr.com/ru/post/903119/


All Articles