选择文本并执行点击操作 [英] Select a text and perform a click action
本文介绍了选择文本并执行点击操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想选择一些文本并执行单击操作-例如在Winword中,我们在选择一些文本后单击Bold
...
I'd like to select some text and perform a click action - like in Winword where we click Bold
after selecting some text...
我必须选择文本,然后单击textarea
中的<B>
粗体图标.
I have to select the text and click on the <B>
bold icon in the textarea
.
关于如何使用Selenium/Webdriver做到这一点的任何想法?
Any idea on how to do this using Selenium/Webdriver?
推荐答案
In Java, The Advanced User Interactions API has your answer.
// 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();
这篇关于选择文本并执行点击操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文