Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 it is not working. I have a extjs button control which acts as button as well as drop down(please refer screen shots).

extjs button cum drop down control

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:

  1. builder.moveToElement(element).moveByOffset(569, 5).click().build().perform();
  2. 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?

like image 431
Mrunal Gosar Avatar asked May 27 '13 12:05

Mrunal Gosar


2 Answers

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();
like image 194
y3rsh Avatar answered Nov 19 '22 17:11

y3rsh


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();
like image 32
Omkar Avatar answered Nov 19 '22 17:11

Omkar