我在下面的代码中使用了多个点,但它仍然没有在画布上画一个点。它甚至没有认识到这一要素。还有其他自动化的选择吗?
WebElement element = driver.findElement(By.xpath("xpath of canvas"));
Actions builder = new Actions(driver);
Action drawAction = builder.moveToElement(element,135,15) //start points x axis and y axis.
.click()
.moveByOffset(200, 60) // 2nd points (x1,y1)
.click()
.moveByOffset(100, 70)// 3rd points (x2,y2)
.doubleClick()
.build();
drawAction.perform();发布于 2020-03-27 23:32:07
使用单击并保持而不是单击,单击只会单击鼠标并突然释放它。
System.setProperty("webdriver.chrome.driver","c:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS) ;
driver.get("http://apps.zetakey.com/signsend/");
Actions builder = new Actions(driver);
Action drawAction = builder.moveToElement(driver.findElement(By.cssSelector("[id='newSignature']"))) //start points x axis and y axis.
.clickAndHold()
.moveByOffset(-50, 60) // 2nd points (x1,y1)
.moveByOffset(-60, -70)// 3rd points (x2,y2)
.moveByOffset(150, 60) // 2nd points (x1,y1)
.moveByOffset(-60, -70)// 3rd points (x2,y
.doubleClick()
.build();
drawAction.perform();
Thread.sleep(6000);阅读更多关于动作课的内容,请访问:
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html
https://sqa.stackexchange.com/questions/43059
复制相似问题