Selenium : Enter the text in div using xpath

前端 未结 3 716
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-06 13:28

In selenium for inputbox, we can enter value like :

WebElement inputBox = driver.findElement(By.xpath(xpath)));
inputBox.sendKeys(\"abc\");

3条回答
  •  不要未来只要你来
    2021-01-06 13:46

    Sendkeys is used to type in the input field with tag name 'input' You cannot use sendkeys here

    Rather you will have to use JavascriptExecutorto do this

    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("document.getElementById('Div_Id').innerHTML="+ DesiredText);
    

提交回复
热议问题