Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用java获取WebDriver的值_Java_Html_Knockout.js_Selenium Webdriver - Fatal编程技术网

无法使用java获取WebDriver的值

无法使用java获取WebDriver的值,java,html,knockout.js,selenium-webdriver,Java,Html,Knockout.js,Selenium Webdriver,请查找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

请查找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">
上面的代码生成一个空值


注意: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;
      }
   });

页面上是否有其他具有相同id但没有此属性的元素??不,不是,这是用于具有validationHave的字段必须尝试任何其他定位符,例如id、xpath等?是的,但我没有得到/*[@id='txtEmail']。GetAttributeToldTitleso你是说,如果您使用xpath,那么您可以在密码字段中获得所需的属性,但不能在电子邮件字段中获得?如果是,那么值很可能是由javascript设置的,因此在访问元素之前,请确保满足错误条件。
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;
      }
   });