简体   繁体   中英

not able to get the value WebDriver using java

Please find the HTMl code

<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

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

Try this. We go in a loop for a maximum of 5 seconds, polling every 500 ms until the apply method returns 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;
      }
   });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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