我要验证的Web应用程序具有一个文本框,该文本框可立即将输入的小写字母转换为大写字母:
<input id="myField" style="text-transform: uppercase; background-color:
rgb(255, 255, 255);" type="text" size="2" maxlength="2" value="">
我想验证当我输入“ ab”时,文本框中会显示“ AB”,但是此代码
driver.findElement( By.id( "myField" ) ).getAttribute( "value" );
只返回与输入内容完全相同的文本(例如“ ab”),然后
driver.findElement( By.id( "myField" ) ).getText();
返回null。
答案 0 :(得分:0)
尝试在获取大写字母之前添加等待时间
String entered_text = "ab";
// WebDriver wait
wait.until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.id("myField")), entered_text.toUpperCase()));