How to click the center of the canvas in Java Selenium Driver?
问题 I'm trying to write the code to click a canvas center in the web page. Here is the code below: private static void clickCanvasCenter() { WebElement we = driver.findElement(By.tagName("canvas")); int x = we.getSize().width/2; int y = we.getSize().height/2; Actions builder = new Actions(driver).moveToElement(new WebDriverWait(driver,20) .until(ExpectedConditions.elementToBeClickable(we))); System.out.println("width:" + x + "\theight:" + y); builder.click().build().perform(); System.out.println(