Когда мы запускали наши тесты на appium в нашей версии 2.4.0, они работали со 100% проходной скоростью. Однако в нашем новом выпуске 2.5.0 некоторые тесты не пройдены.
Они терпят неудачу, потому что на некоторых экранах они не могут найти элемент. Идентификаторы элементов в 2.5.0 точно такие же, как и в 2.4.0.
Я убедился, что он ожидает загрузки экрана. Происходит следующее: он проходит через несколько экранов, затем всегда застревает на одном и том же экране и остается там в течение установленного мною периода времени ожидания, а затем не может сказать, что не смог найти элемент.
Вот журналы приложения, когда тест попадает на экран ввода имени. Должно найти поле имени и отправить текст.
> [debug] [MJSONWP] Calling AppiumDriver.findElement() with args:
> ["id","Step3.firstname","489801e6-96d8-45f8-9712-0c2ec940413b"]
> [debug] [BaseDriver] Valid locator strategies for this request: xpath,
> id, class name, accessibility id, -android uiautomator [debug]
> [BaseDriver] Waiting up to 0 ms for condition [debug]
> [AndroidBootstrap] Sending command to android:
> {"cmd":"action","action":"find","params":{"strategy":"id","selector":"Step3.firstname","context":"","multiple":false}}
> [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from
> client:
> {"cmd":"action","action":"find","params":{"strategy":"id","selector":"Step3.firstname","context":"","multiple":false}}
> [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type
> ACTION [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command
> action: find [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]
> Finding 'Step3.firstname' using 'ID' with the contextId: '' multiple:
> false [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[INSTANCE=0,
> RESOURCE_ID=com.readytouchpos.smallstore:id/Step3.firstname] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[INSTANCE=0, RESOURCE_ID=android:id/Step3.firstname] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[INSTANCE=0, RESOURCE_ID=Step3.firstname] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[DESCRIPTION=Step3.firstname, INSTANCE=0] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element.
> Clearing Accessibility cache and retrying. [debug] [AndroidBootstrap]
> [BOOTSTRAP LOG] [debug] Finding 'Step3.firstname' using 'ID' with the
> contextId: '' multiple: false [debug] [AndroidBootstrap] [BOOTSTRAP
> LOG] [debug] Using: UiSelector[INSTANCE=0,
> RESOURCE_ID=com.readytouchpos.smallstore:id/Step3.firstname] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[INSTANCE=0, RESOURCE_ID=android:id/Step3.firstname] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[INSTANCE=0, RESOURCE_ID=Step3.firstname] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using:
> UiSelector[DESCRIPTION=Step3.firstname, INSTANCE=0] [debug]
> [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result:
> {"status":7,"value":"No element found"} [debug] [AndroidBootstrap]
> Received command result from bootstrap [debug] [MJSONWP] Matched
> JSONWP error code 7 to NoSuchElementError [debug] [MJSONWP]
> Encountered internal error running command: NoSuchElementError: An
> element could not be located on the page using the given search
> parameters. [debug] [MJSONWP] at AndroidDriver.callee$0$0$
> (C:\Users\arroy\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
> [debug] [MJSONWP] at tryCatch
> (C:\Users\arroy\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
> [debug] [MJSONWP] at GeneratorFunctionPrototype.invoke [as
> _invoke] (C:\Users\arroy\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
> [debug] [MJSONWP] at
> GeneratorFunctionPrototype.prototype.(anonymous function) [as throw]
> (C:\Users\arroy\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
> [debug] [MJSONWP] at GeneratorFunctionPrototype.invoke
> (C:\Users\arroy\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
> [debug] [MJSONWP] at <anonymous>
Вот метод, используемый для отправки ключей в поле имени:
> public EnterNameScreen typeFirstName(String firstName){
> waitForElement(firstNameTextBox).sendKeys(firstName);
> return this;
> }
Вот метод ожидания, который используется в методе typeFirstName:
protected WebElement waitForElement(By locator) {
int count = 0;
int maxTries = 3;
while(true) {
try {
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOfElementLocated((locator)));
return driver.findElement(locator);
} catch (Exception e) {
// handle exception
if (++count == maxTries) throw e;
}
}
}
Имейте в виду, что они работали безупречно в нашей версии 2.4.0. Только в нашем новом выпуске 2.5.0 это перестало работать. Некоторые кнопки все еще нажимаются, как и ожидалось, а некоторые поля по-прежнему получают отправленный текст, как и ожидалось, но некоторые, как в этом примере выше, нет.
У кого-нибудь было такое раньше? Может ли это быть библиотека, которая была обновлена в приложении, чтобы вызвать это?