有人可以给我一个提示来定位 Selenium 中的元素吗?
我尝试选择的内容在哪里
WebElement hello = driver.findElement(By.className("input-box"));
Eclipse 错误:
Can't find symbol 'GetGraphicsResetStatus'.
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: .input\-box
再次感谢您。
原始html
<div data-v-7d31c51a="" data-v-126e1ccf="" class="input-box"><textarea data-v-7d31c51a="" placeholder="inputhere~" maxlength="500" autofocus="autofocus" class="textarea" style="height: 60px;"></textarea><div data-v-7d31c51a="" class="indicator" style="bottom: -30px; right: 100px;"><span data-v-7d31c51a="" class="">0</span>/<span data-v-7d31c51a="">500</span></div></div>
尝试时出错 WebElement hello = driver.findElement(By.className("textarea"));
找不到符号“GetGraphicsResetStatus”。 线程“main”中的异常 org.openqa.selenium.NoSuchElementException:无法找到元素:.textarea 有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html 构建信息:版本:'3.6.0',修订版:'6fbf3ec767',时间:'2017-09-27T16:15:26.402Z'
添加我的 jar 文件和代码
最佳答案
尝试 xpath:
WebElement hello = driver.findElement(By.xpath("//div[@placeholder='inputhere~']"));
关于java - 如何通过 Selenium 和 Java 在元素内插入文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55058057/