选择文本并执行单击操作

smr*_*iti 5 selenium webdriver selenium-webdriver

我想选择一些文本并执行点击操作 - 比如在Winword中我们Bold在选择一些文本后单击...

我必须选择文本,然后单击中的<B>粗体图标textarea.

有关如何使用Selenium/Webdriver进行此操作的任何想法?

Pet*_*ček 8

在Java中,高级用户交互API具有您的答案.

// the element containing the text
WebElement element = driver.findElement(By.id("text"));
// assuming driver is a well behaving WebDriver
Actions actions = new Actions(driver);
// and some variation of this:
actions.moveToElement(element, 10, 5)
    .clickAndHold()
    .moveByOffset(30, 0)
    .release()
    .perform();
Run Code Online (Sandbox Code Playgroud)