我正在尝试在Chrome中用Java复制Selenium Webdriver中的一段。基本上,我试图通过移动鼠标光标选择段落的上部(从中心开始),按住控制按钮,通过移动鼠标光标选择段落的其余部分,按“ C”,然后松开控制按钮。这曾经起作用,但现在不再起作用。没有选择该段落的下部。我的方法如下:
void CopyParagraph(Actions build, WebDriver driver, String xpath, int x1, int y1, int x2, int y2) {
// Selects and copies paragraph from a web page using a web element as a reference point.
// Receives actions object, web driver, web element xpath as well as lower right hand corner and upper left hand corner x and y coordinates.
WebElement start = driver.findElement(By.xpath(xpath));
build.dragAndDropBy(start, x1, y1).keyDown(Keys.CONTROL).dragAndDropBy(start, x2, y2).sendKeys("c").keyUp(Keys.CONTROL);
Action selectParagraph = build.build();
selectParagraph.perform();
}
如何在Selenium Java中复制整个段落?