我正在使用Selenium 3.14.0和IE11,IEDriverServer_Win32_3.14.0

      /**
 * try for 5 attemps to find element
 *
 * @param element
 */
public void Attempt_Find_Element(WebElement element) {
    int numAttemps = 0;
    int specifiedAttempts = 30;
    boolean success = false;

    do {
        numAttemps++;
        try {
            // access the element
            success = element.isDisplayed();
            // success = true; //<--If it reaches here
     means success
        } catch (NoSuchElementException |
   StaleElementReferenceException  nse) {
            // one attempt failed
        }
    } while (!success || numAttemps < specifiedAttempts);

    if (!success) {
        System.out.println("Couldn't load after " + numAttemps
   + " attempts");
    }
}


我收到以下异常:

org.openqa.selenium.WebDriverException: Returned value cannot be
converted to Boolean: Error executing JavaScript
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-
02T20:19:58.91Z'System info: host: 'MAROC89', ip: '192.168.220.71',
os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version:
'1.8.0_161'Driver info: driver.version: unknown


任何想法,请,如果您可以向我建议使用IE的其他版本

最佳答案

尝试一下,因为您需要返回以下内容:

 public boolean Attempt_Find_Element(WebElement element) {
  int numAttemps = 0;
  int specifiedAttempts = 30;
  boolean success = false;

  do {
   numAttemps++;
   try {
    success = element.isDisplayed();
   } catch (NoSuchElementException | StaleElementReferenceException nse) {

   }
  } while (!success || numAttemps < specifiedAttempts);
  if (!success) {
   System.out.println("Couldn't load after " + numAttemps + " attempts");
  }
  return success;
 }

关于selenium - 使用Selenium和IE和IEdriverServer的自动化测试问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56854804/

10-10 16:39