Select a text and perform a click action

后端 未结 3 1821
故里飘歌
故里飘歌 2021-02-04 15:35

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 cl

3条回答
  •  萌比男神i
    2021-02-04 16:12

    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();
    

提交回复
热议问题