我想在<pre> tag using Selenium Webdriver

时间:2019-02-21 04:59:12

标签: javascript selenium-webdriver automation

[enter image description here][1] I am not able to insert any data in tag. I always show Element is not reachable through Keyboard. It is possible through Javascript to insert. PLS help......XPath is not working. I am adding the to rectify. OR If this is not problem of then how to inert data in provided field.

[1]: https://i.stack.imgur.com/Qk74u.png

1 个答案:

答案 0 :(得分:1)

以下代码将解决您的问题

By preTagXpath = By.xpath("//pre");
        JavascriptExecutor js = (JavascriptExecutor) driver;
        String preValue = "This should be the new value";
        js.executeScript("document.getElementsByTagName('pre')[0].innerText='" + preValue + "';");
        System.out.println(driver.findElement(preTagXpath).getText());