I tried using sendKeys() method on webelement but it does not work. Does anyone has any idea if this can be achieved ?
Please find below the html.
<div class="CodeMirror-code" style="">
<div style="position: relative;">
<div style="position: absolute; left: -51px;">
**<pre>**
</pre>
</div>
</div>
</div>
答案 0 :(得分:1)
请尝试以下代码:
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElement(By.xpath('//div[@class="CodeMirror-code"]//p'));
js.executeScript('arguments[0].innerHTML = "text goes here";', element);