如何在Selenium Java中使用键盘键复制段落

问题描述 投票:0回答:1

我正在尝试在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中复制整个段落?

java selenium
1个回答
0
投票
很抱歉,如果这不是您想要的答案。
© www.soinside.com 2019 - 2024. All rights reserved.