Selenium moveByOffset doesn't do anything

前端 未结 5 1959
轻奢々
轻奢々 2021-01-06 17:08

I\'m running latest selenium 2.41 with Firefox 28.0 on Linux Xubuntu 13.10

I\'m trying to get FirefoxDriver to move the mouse over the page (in my test, I\'ve used

5条回答
  •  孤城傲影
    2021-01-06 17:32

    i was also struggling with this and the solution that worked for me is below we have to add 1 to either X or Y co-ordinate.

    Looks like (x,y) takes us to the edge of the element where its not clickable

    Below worked for me

        WebElement elm = drv.findElement(By.name(str));
    
        Point pt = elm.getLocation();
    
        int NumberX=pt.getX();
        int NumberY=pt.getY();
    
        Actions act= new Actions(drv);
        act.moveByOffset(NumberX+1, NumberY).click().build().perform();
    

    you could even try adding +1 to y coordinate that also works

       act.moveByOffset(NumberX+1, NumberY).click().build().perform(); 
    

提交回复
热议问题