简体   繁体   English

无法使用Java获取值WebDriver

[英]not able to get the value WebDriver using java

Please find the HTMl code 请找到HTMl代码

<input type="password" maxlength="20" id="txtRegPassword" data-bind="value: Password,   valueUpdate: 'afterkeydown',qtipValMessage:Password" class="input-txt ErrorControl" data-orig-  title="" data-hasqtip="3" oldtitle="Password doesn't meet the Password Policy." title="" aria-describedby="qtip-3">

my requirement it get the oldtitle value ("Password doesn't meet the Password Policy) 我的要求是获取旧标题值(“密码不符合密码政策”)

following are my code(Java) but i'm getting null value 以下是我的代码(Java),但我得到空值

String Validationmessagepwd = driver.findElement(
            By.cssSelector("input#txtRegPassword")).getAttribute("oldtitle");

the above code produce an null value 上面的代码产生一个空值

Note: oldtitle (Dynamic) attribute binding with KO (Knockout JS) Binding so that i'm not able to getting this, Please guide 注意:oldtitle(动态)属性绑定与KO(Knockout JS)绑定使我无法获取此信息,请指导

Try this. 尝试这个。 We go in a loop for a maximum of 5 seconds, polling every 500 ms until the apply method returns true. 我们最多循环5秒钟,每500毫秒轮询一次,直到apply方法返回true。

WebDriverWait wait = new WebDriverWait(driver,5).until(new ExpectedCondition<Boolean>() {    
   public Boolean apply(WebDriver driver) {
      WebElement inputElement= driver.findElement(By.cssSelector("input#txtRegPassword"));

      if(inputElement.getAttribute("oldtitle") == null) 
         return false;
      } else {
         return true;
      }
   });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM