Java 使用Selenium从只读文本框获取动态文本
我有一个文本框,其中包含从1到24的小时数。当我们单击文本框上方和下方的向上箭头和向下箭头(Hyperlinka)时,小时会增加或减少 这是我的文本框的代码Java 使用Selenium从只读文本框获取动态文本,java,selenium,textbox,selenium-webdriver,Java,Selenium,Textbox,Selenium Webdriver,我有一个文本框,其中包含从1到24的小时数。当我们单击文本框上方和下方的向上箭头和向下箭头(Hyperlinka)时,小时会增加或减少 这是我的文本框的代码 <input type="text" ng-model="hours" ng-change="updateHours()" class="form-control text-center ng-pristine ng-valid" ng-mousewheel="incrementHours()" ng-readonly="read
<input type="text" ng-model="hours" ng-change="updateHours()"
class="form-control text-center ng-pristine ng-valid"
ng-mousewheel="incrementHours()" ng-readonly="readonlyInput"
maxlength="2" readonly="readonly">
任何人都可以在这方面提供帮助。找到输入并获取
value
属性的值:
WebElement input = driver.findElement(By.xpath('//input[@ng-model="hours"]'));
System.out.println(input.getAttribute("value"));
我得到了这个例外。(org.openqa.selenium.NoSuchElementException:无此类element@Vikram好的,关于
WebElement input=driver.findelelement(By.xpath(properties.getProperty(“Hours”));
?@Vikram页面上有iframe
或frame
标记吗?谢谢。给我2分钟时间,我会保持延迟并检查一下。谢谢
WebElement input = driver.findElement(By.xpath('//input[@ng-model="hours"]'));
System.out.println(input.getAttribute("value"));