selenium - Selenium RC 中发生异常 : org. openqa.selenium.InvalidSelectorException

标签 selenium

当我尝试从文本框中获取值时,它抛出“没有找到这样的元素”问题,

以下是我的字段属性:

input id="altid" class="firstColumnInput text C1 disabled" type="text" value="100281" securityidpath="MEMBER_DEMOGRAPHICS.INDICATIVE_INFORMATION.INDICATIVE_INFORMATION.PERSON.ALT_IDENTIFIER" name="$EntryField$7" lockrequired="true" tabindex="-1" readonly="readonly"

获取值的代码是:

driver.findElement(By.xpath(OR.getProperty(object))).getAttribute("value");

结果:

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id=\"age\"]"} For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.2.0', revision: '13073', time: '2011-07-25 19:23:22' System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22' Driver info: driver.version: EventFiringWebDriver

请建议我如何解决此问题。

最佳答案

尝试使用 xpath 和输入的 id 进行搜索,例如:

driver.findElement(By.xpath("//*[@id=\"altid\"]")).getAttribute("value");

关于selenium - Selenium RC 中发生异常 : org. openqa.selenium.InvalidSelectorException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8502283/

相关文章:

c# - 操作类不接受 Selenium 驱动程序作为变量

java - Selenium Webdriver startWith() 方法在 Java 中不起作用

python - 选择同一节点的元素

python - 无法在pycharm中使用pabot运行并行robotframework测试

c# - Selenium - 查找应用的 CSS 样式

Python Selenium 无法通过 xpath 找到表元素

selenium - 操作系统错误: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver' error using Chromedriver in AWS EC2 ARM flavour machine

java - Webdriver/Xpath/Java : Crawl DOM to click on 'Element with No Unique Identifier'

Java Selenium-link missing field 错误警告给字段

通过 Selenium chromedriver 进行 Python 代理身份验证