так что я немного новичок в Appium и не могу сказать, что все настроил так, как должно быть, но до сих пор все шло так, как должно было до сих пор:)
В основном я настраиваю тестсреда в настройках разработчика самого приложения.Для этого я щелкаю пункт меню, выбираю среду в списке, а затем хочу проверить, что пункт меню содержит имя желаемой среды, и именно здесь Appium не может найти элемент, даже если он не был найден с тем жеxpath и все.Используя Appium Inspector, я могу сделать этот сценарий без проблем, и переопределение элемента с тем же xpath работает, как и ожидалось, но при запуске этого сценария через WebDriver он не работает.
Java: 1.8.0_201
Android Emulator: 28.0.25
Android SDK Platform Tools: 28.0.2
Android SDK Tools: 26.1.1
Appium Desktop: 1.12.1
Мои возможности:
{
"locale": "EN",
"language": "en",
"avd": "Nexus6",
"deviceName": "Nexus6",
"platformName": "Android",
"platformVersion": "8.0",
"appPackage": "de.safas.android.dab",
"appActivity": "de.safas.main.SafasApp",
"app": "T:/consumer-debug-p05.00.apk",
"noReset": true,
"skipUnlock": true,
"noResetValue": true,
"useJSONSource": true,
"simpleIsVisibleCheck": true,
"autoGrantPermissions": true,
"newCommandTimeout": 160000,
"automationName": "UiAutomator2"
}
рассматриваемый код:
def driver = TestDriver.getWebDriver() as AndroidDriver
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS)
// get current selected environment (part is not included now)
final btnHostBySelector = MobileBy.xpath(".//android.widget.TextView[starts-with(@text, 'Selected host environment')]")
def btnHostWebElement = driver.findElement(btnHostBySelector)
println "text before: ${btnHostWebElement.getText()}"
// open list
btnHostWebElement.click()
// select entry
final optHostsByLocator = MobileBy.xpath(".//android.widget.CheckedTextView")
def optHostsWebElement = driver.findElements(optHostsByLocator)
optHostsWebElement.find { it.getText().equalsIgnoreCase(testEnv) }.click()
println "entry selected"
// verify selection after returning back from the list
btnHostWebElement = driver.findElement(btnHostBySelector) // <-- not working anymore
println "text after: ${btnHostWebElement.getText()}"
WebDriverException
выбрасывается только после очень очень долгого времени ожидания, по крайней мере, 10 минут, в течение которых тест ожидает соединения ?!Журнал консоли:
24.04.2019 18:07:52.899 [#01] > findElement(By.xpath: .//android.widget.TextView[starts-with(@text, 'Selected host environment')])
text before: Selected host environment RESERVE2
entry selected
org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{127.0.0.1:4723, proxy=DIRECT hostAddress=/127.0.0.1:4723 cipherSuite=none protocol=http/1.1}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'RYZEN5', ip: '192.168.0.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:254)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:152)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.MobileDriver$findElement.call(Unknown Source)
...
Caused by: java.io.IOException: unexpected end of stream on Connection{127.0.0.1:4723, proxy=DIRECT hostAddress=/127.0.0.1:4723 cipherSuite=none protocol=http/1.1}
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:208)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at org.openqa.selenium.remote.internal.OkHttpClient$Factory$1.lambda$createClient$1(OkHttpClient.java:152)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:155)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:152)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.MobileDriver$findElement.call(Unknown Source)
...
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:237)
at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
... 62 more
при 06:42:26
- это задержка 10 минут в журнале приложения:
[2019-04-24 06:40:25][HTTP] --> POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/elements
[2019-04-24 06:40:25][HTTP] {"using":"xpath","value":".//android.widget.CheckedTextView"}
[2019-04-24 06:40:25][W3C (94274fbe)] Calling AppiumDriver.findElements() with args: ["xpath",".//android.widget.CheckedTextView","94274fbe-b200-42a9-8eac-baff6b0e4e60"]
[2019-04-24 06:40:25][BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[2019-04-24 06:40:25][BaseDriver] Waiting up to 5000 ms for condition
[2019-04-24 06:40:25][AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":".//android.widget.CheckedTextView","context":"","multiple":true}}
[2019-04-24 06:40:25][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":".//android.widget.CheckedTextView","context":"","multiple":true}}
[2019-04-24 06:40:25][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[2019-04-24 06:40:25][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[2019-04-24 06:40:25][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding './/android.widget.CheckedTextView' using 'XPATH' with the contextId: '' multiple: true
[2019-04-24 06:40:25][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[2019-04-24 06:40:25][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding './/android.widget.CheckedTextView' using 'XPATH' with the contextId: '' multiple: true
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=0]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=0]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=1]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=1]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=2]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=2]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=3]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=3]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=4]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=4]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=5]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=5]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=6]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=6]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=7]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=7]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=8]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLASS=android.widget.CheckedTextView, INSTANCE=8]
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Selector ends with instance.
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"139"},{"ELEMENT":"140"},{"ELEMENT":"141"},{"ELEMENT":"142"},{"ELEMENT":"143"},{"ELEMENT":"144"},{"ELEMENT":"145"},{"ELEMENT":"146"},{"ELEMENT":"147"}]}
[2019-04-24 06:40:26][AndroidBootstrap] Received command result from bootstrap
[2019-04-24 06:40:26][W3C (94274fbe)] Responding to client with driver.findElements() result: [{"element-6066-11e4-a52e-4f735466cecf":"139","ELEMENT":"139"},{"element-6066-11e4-a52e-4f735466cecf":"140","ELEMENT":"140"},{"element-6066-11e4-a52e-4f735466cecf":"141","ELEMENT":"141"},{"element-6066-11e4-a52e-4f735466cecf":"142","ELEMENT":"142"},{"element-6066-11e4-a52e-4f735466cecf":"143","ELEMENT":"143"},{"element-6066-11e4-a52e-4f735466cecf":"144","ELEMENT":"144"},{"element-6066-11e4-a52e-4f735466cecf":"145","ELEMENT":"145"},{"element-6066-11e4-a52e-4f735466cecf":"146","ELEMENT":"146"},{"element-6066-11e4-a52e-4f735466cecf":"147","ELEMENT":"147"}]
[2019-04-24 06:40:26][HTTP] <-- POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/elements 200 888 ms - 569
[2019-04-24 06:40:26][HTTP]
[2019-04-24 06:40:26][HTTP] --> GET /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element/139/text
[2019-04-24 06:40:26][HTTP] {}
[2019-04-24 06:40:26][W3C (94274fbe)] Calling AppiumDriver.getText() with args: ["139","94274fbe-b200-42a9-8eac-baff6b0e4e60"]
[2019-04-24 06:40:26][AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getText","params":{"elementId":"139"}}
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getText","params":{"elementId":"139"}}
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getText
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"..."}
[2019-04-24 06:40:26][AndroidBootstrap] Received command result from bootstrap
[2019-04-24 06:40:26][W3C (94274fbe)] Responding to client with driver.getText() result: "..."
[2019-04-24 06:40:26][HTTP] <-- GET /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element/139/text 200 10 ms - 17
...
[2019-04-24 06:40:26][HTTP]
[2019-04-24 06:40:26][HTTP] --> POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element/141/click
[2019-04-24 06:40:26][HTTP] {"id":"141"}
[2019-04-24 06:40:26][W3C (94274fbe)] Calling AppiumDriver.click() with args: ["141","94274fbe-b200-42a9-8eac-baff6b0e4e60"]
[2019-04-24 06:40:26][AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"141"}}
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"141"}}
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[2019-04-24 06:40:26][AndroidBootstrap] Received command result from bootstrap
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[2019-04-24 06:40:26][W3C (94274fbe)] Responding to client with driver.click() result: true
[2019-04-24 06:40:26][HTTP] <-- POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element/141/click 200 161 ms - 14
[2019-04-24 06:40:26][HTTP]
[2019-04-24 06:40:26][HTTP] --> POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element
[2019-04-24 06:40:26][HTTP] {"using":"xpath","value":".//android.widget.TextView[starts-with(@text, 'Selected host environment')]"}
[2019-04-24 06:40:26][W3C (94274fbe)] Calling AppiumDriver.findElement() with args: ["xpath",".//android.widget.TextView[starts-with(@text, 'Selected host environment')]","94274fbe-b200-42a9-8eac-baff6b0e4e60"]
[2019-04-24 06:40:26][BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[2019-04-24 06:40:26][BaseDriver] Waiting up to 5000 ms for condition
[2019-04-24 06:40:26][AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":".//android.widget.TextView[starts-with(@text, 'Selected host environment')]","context":"","multiple":false}}
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":".//android.widget.TextView[starts-with(@text, 'Selected host environment')]","context":"","multiple":false}}
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[2019-04-24 06:40:26][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding './/android.widget.TextView[starts-with(@text, 'Selected host environment')]' using 'XPATH' with the contextId: '' multiple: false
[2019-04-24 06:42:26][HTTP] <-- POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element - - ms - -
[2019-04-24 06:42:26][HTTP]
[2019-04-24 06:42:26][HTTP] --> POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element
[2019-04-24 06:42:26][HTTP] {"using":"xpath","value":".//android.widget.TextView[starts-with(@text, 'Selected host environment')]"}
[2019-04-24 06:42:26][W3C (94274fbe)] Calling AppiumDriver.findElement() with args: ["xpath",".//android.widget.TextView[starts-with(@text, 'Selected host environment')]","94274fbe-b200-42a9-8eac-baff6b0e4e60"]
[2019-04-24 06:52:26][HTTP] <-- POST /wd/hub/session/94274fbe-b200-42a9-8eac-baff6b0e4e60/element - - ms - -
[2019-04-24 06:52:26][HTTP]
сценарий в картинках:
- Проверьте имя
RESERVE2
записи с помощью Selected host environment
- Щелкните по записи, чтобы открыть список со всеми средами
- Выберите нужную среду хоста
RESERVE1
- Проверьте имя
RESERVE1
записи с помощью Selected host environment
и 4. больше не можете найти запись.Даже driver.getPageSource()
больше не работает и также имеет это исключение с 10-минутным таймаутом.Что происходит?: D
Обновление : похоже, что эта проблема не возникает, если я установлю automationName
на UiAutomator2
, но я все равно хотел бы знать, есть ли в моем сценарии что-то, что делаетэто так плохо или если это просто Аппиум