I am trying to use moveToElement(element,xoffset,yoffset)
of the Actions class in selenium web driver (java) in FireFox 21. but it seems it is not working. I have a extjs button control which acts as button as well as drop down(please refer screen shots).
When i click on the Save Changes section it saves the changes and when i am clickin on the drop down button attached to it, it opens up the list. please refer 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 am able to click on the Save Changes button but i am not able to click on the drop down button by giving some offset position in the moveToElement method.
I have tried below two options:
builder.moveToElement(element).moveByOffset(569,
5).click().build().perform();
builder.moveToElement(element, 568, 5).click().build().perform();
but both are not working.
The dimensions of the control are (117 x 16)
Note: do not get confused by offsets 568,5 as this offsets are still able to click on the save changes button.
Is it that this method is not yet supported in latest web driver?
I had the same issue. Using ClickAndHold()
and Release()
worked when Click()
did not. I also like using percentages on any x,y coordinates so they are relative. May or may not help you. 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();
Similar problem i solved by using below code may be this helpful for you,Try first find out the x and y offset.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With