MoveToElement (element, xoffset, yoffset) not working in selenium webdriver 2.32.0

I am trying to use moveToElement(element,xoffset,yoffset) of the Actions class in selenium web driver (java) in FireFox 21. but it seems to not work. I have an extjs button control button that acts like a button as well as a dropdown (please view screenshots).

extjs button cum drop down control

When I click on the “Save Changes” section, it saves the changes, and when I click the “down” button attached to it, it opens the list. refer to the DOM source for the same control.

 <td class="x-btn-mc"><em id="ext-gen514" class="x-btn-split" unselectable="on"><button id="btn-ext-comp-1739" class=" x-btn-text save-changes" type="button"><u> S </u> ave Changes </button></em></td> 

Now I can click on the “Save Changes” button, but I can’t click on the “drop down” button, providing some offset position in the moveToElement method.

I tried two options:

  • builder.moveToElement(element).moveByOffset(569, 5).click().build().perform();
  • builder.moveToElement(element, 568, 5).click().build().perform();

but both of them do not work.

Control Dimensions (117 x 16)

Note. do not confuse offsets 568.5, as these offsets can still press the save changes button.

Is this method not yet supported in the latest web driver?

+4
source share
3 answers

I had the same problem. Using ClickAndHold() and Release() worked when Click() did not. I also like to use percentages for any x, y coordinates, so they are relative. It may or may not help. C # below.

  IWebElement MarkAs = MarkAsSpan(driver).FindElement(By.Id("btnMarkAs")); int Width = MarkAs.Size.Width; int Height = MarkAs.Size.Height; int MyX = (Width * 95) / 100;//spot to click is at 95% of the width int MyY = 1;//anywhere above Height/2 works Actions Actions = new Actions(driver); Actions.MoveToElement(MarkAs,MyX,MyY); Actions.ClickAndHold(); Actions.Release(); Actions.Perform(); 
+4
source

A similar problem that I solved with the code below may be useful to you, try to find out the x and y offsets first.

  driver= new FirefoxDriver(); driver.manage().window().maximize(); driver.get("http://dev.sencha.com/deploy/ext-4.0.0/examples/toolbar/toolbars.html"); driver.findElement(By.xpath("//em")).click(); System.out.println(driver.findElement(By.xpath("//em")).getSize()); Actions action = new Actions(driver); action.moveToElement(driver.findElement(By.xpath("//em")), 97, 16).click().build().perform(); 
+1
source

Mrunal,

Using the code below you can move the mouse in webdriver (java)

 Actions actions = new Actions(driver); WebElement imageSpan = driver.findElement(By.className("badgeFeatured")); actions.moveToElement(imageSpan); WebElement subLink = driver.findElement(By.cssSelector("#headerMenu .subLink")); actions.moveToElement(subLink); actions.click(); actions.perform(); 
0
source

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


All Articles