Проблема автоматизации тестирования с использованием Selenium, IE и IEdriverServer - PullRequest
0 голосов
/ 02 июля 2019

Я использую 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

1 Ответ

0 голосов
/ 02 июля 2019

Попробуйте, потому что вам нужно что-то вернуть:

 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;
 }
...