簡體   English   中英

無法使用Java獲取值WebDriver

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

請找到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">

我的要求是獲取舊標題值(“密碼不符合密碼政策”)

以下是我的代碼(Java),但我得到空值

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

上面的代碼產生一個空值

注意:oldtitle(動態)屬性綁定與KO(Knockout JS)綁定使我無法獲取此信息,請指導

嘗試這個。 我們最多循環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