Clicking at coordinates without identifying element

前端 未结 14 1923
醉酒成梦
醉酒成梦 2020-11-28 07:49

As part of my Selenium test for a login function, I would like to click a button by identifying its coordinates and instructing Selenium to click at those coordinates. This

14条回答
  •  无人及你
    2020-11-28 08:20

        WebElement button = driver.findElement(By.xpath("//button[@type='submit']"));
        int height = button.getSize().getHeight();
        int width = button.getSize().getWidth();
        Actions act = new Actions(driver);
        act.moveToElement(button).moveByOffset((width/2)+2,(height/2)+2).click();
    

提交回复
热议问题