【发布时间】:2018-04-17 12:12:38
【问题描述】:
我想在文本区域内发送密钥“描述”。我已经尝试了所有可能的方法,但都不起作用。
元素的HTML:
<div class="ta-scroll-window ng-scope ta-text ta-editor form-control" ng-hide="showHtml">
<div class="popover fade bottom" style="max-width: none; width: 305px;">
<div class="arrow"></div>
<div class="popover-content"></div>
</div>
<div class="ta-resizer-handle-overlay">
<div class="ta-resizer-handle-background"></div>
<div class="ta-resizer-handle-corner ta-resizer-handle-corner-tl"></div>
<div class="ta-resizer-handle-corner ta-resizer-handle-corner-tr"></div>
<div class="ta-resizer-handle-corner ta-resizer-handle-corner-bl"></div>
<div class="ta-resizer-handle-corner ta-resizer-handle-corner-br"></div>
<div class="ta-resizer-handle-info"></div>
</div>
<div id="taTextElement737852736512107" contenteditable="true" ta-bind="ta-bind" ng-model="html" ta-keep-styles="true" class="ng-pristine ng-valid ta-bind ng-empty ng-touched" an-form-object-name="Açıklama" name="Açıklama">
<p>
<br>
</p>
</div>
</div>
代码试用:
Dim action2 = New Actions(driver)
Dim cekbul2 = driver.FindElement(By.XPath("//*@id=""taHtmlElement737852736512107""]"))
cekbul2.SendKeys("Açıklama")
Console.Write("textarea send description")
或
Dim cekbul2 = driver.FindElement(By.XPath("//textarea[@class='ng-pristine ng-untouched ng-valid ng-scope ta-bind ta-html ta-editor form-control ng-empty ng-hide' and @id='taHtmlElement737852736512107']"))
错误是:
"no such element: Unable to locate element does not work" give error
【问题讨论】:
-
does not work非常模糊。错误?是否找到元素?找到但没有输入文字? -
"没有这样的元素:无法定位元素:"错误给出
-
我在您提供的 HTML 中没有看到任何
<textarea>标记 -
invalid selector: Unable to locate an element with the xpath expression //*@id="taHtmlElement737852736512107"] 因为以下错误:SyntaxError: 无法在“文档”上执行“评估”: string '//*@id="taHtmlElement737852736512107"]' 不是有效的 XPath 表达式。这个错误给
-
你确定 xpath 是(或可能是)你想要的元素吗
标签: c# selenium selenium-webdriver xpath webdriver