I'd like to select some text and perform a click action - like in Winword where we click Bold
after selecting some text...
I have to select the text and click on the <B>
bold icon in the textarea
.
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();
I tried with Action
builder
and played with offset
. It worked for me.
Actions action = new Actions(driver);
action.moveToElement(wblmt,3,3).click().keyDown(Keys.SHIFT).moveToElement(wblmt,200, 0).click().keyUp(Keys.SHIFT).build().perform();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With