Appium: элемент не идентифицирован во время пробного запуска - PullRequest
0 голосов
/ 20 ноября 2018

Я получил локаторы с помощью инспектора аппиума.Полученный элемент хорошо работает во время записи в контроллере прибора.Но когда я запускаю тестовый пример, appium не может определить элемент.Ниже находится лог на сервере

    [JSONWP Proxy] Proxying [POST /session] to [POST 
    http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.chrome","androidDeviceSerial":"3208c623a27f61e9"}}}
[Chromedriver] Webview version: 'Chrome/63.0.3239.111'
[JSONWP Proxy] Got response with status 200: {"sessionId":"a577f16ef658470ccbc8066131f27b70","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"setWindowRect":false,"takesHeapSnapshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"63.0.3239.111","webStorageEnabled":true}}
[Chromedriver] Changed state to 'online'
[Appium] New AndroidDriver session created successfully, session 9aa0ede8-867f-41a1-b4c9-61416598aaf0 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1542707446213 (15:20:46 GMT+0530 (India Standard Time))
[MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"browserName":"chrome","platformName":"Android","deviceName":"3208c623a27f61e9"},"browserName":"chrome","platformName":"Android","deviceName":"3208c623a27f61e9","deviceUDID":"3208c623a27f61e9","platformVersion":"6.0.1","deviceScreenSize":"1080x1920","deviceModel":"SM-G900H","deviceManufacturer":"samsung"}
[HTTP] <-- POST /wd/hub/session 200 33062 ms - 584 
[HTTP] --> POST /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0/url {"url":"https://www.google.com"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Proxying [POST /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0/url] to [POST http://127.0.0.1:8000/wd/hub/session/a577f16ef658470ccbc8066131f27b70/url] with body: {"url":"https://www.google.com"}
[JSONWP Proxy] Got response with status 200: {"sessionId":"a577f16ef658470ccbc8066131f27b70","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId a577f16ef658470ccbc8066131f27b70 with 9aa0ede8-867f-41a1-b4c9-61416598aaf0
[HTTP] <-- POST /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0/url 200 4603 ms - 76 
[HTTP] --> POST /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0/element {"using":"xpath","value":"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout[2]/android.webkit.WebView/android.view.View/android.view.View[3]/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View[3]"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Proxying [POST /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0/element] to [POST http://127.0.0.1:8000/wd/hub/session/a577f16ef658470ccbc8066131f27b70/element] with body: {"using":"xpath","value":"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout[2]/android.webkit.WebView/android.view.View/android.view.View[3]/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View[3]"}
[JSONWP Proxy] Got response with status 200: {"sessionId":"a577f16ef658470ccbc8066131f27b70","status":7,"value":{"message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout[2]/android.webkit.WebView/android.view.View/android.view.View[3]/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View[3]\"}\n  (Session info: chrome=63.0.3239.111)\n  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.14393 x86_64)"}}
[JSONWP Proxy] Replacing sessionId a577f16ef658470ccbc8066131f27b70 with 9aa0ede8-867f-41a1-b4c9-61416598aaf0
[HTTP] <-- POST /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0/element 200 205 ms - 733 
[HTTP] --> DELETE /wd/hub/session/9aa0ede8-867f-41a1-b4c9-61416598aaf0 {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["9aa0ede8-867f-41a1-b4c9-61416598aaf0"]
[BaseDriver] Event 'quitSessionRequested' logged at 1542707451117 (15:20:51 GMT+0530 (India Standard Time))
[Appium] Removing session 9aa0ede8-867f-41a1-b4c9-61416598aaf0 from our master session list
[AndroidDriver] Shutting down Android driver
[AndroidDriver] Stopping chromedriver for context CHROMIUM
[Chromedriver] Changed state to 'stopping'
[JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8000/wd/hub/session/a577f16ef658470ccbc8066131f27b70] with no body
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"a577f16ef658470ccbc8066131f27b70\",\"status\":0,\"value\":null}"
[Chromedriver] Changed state to 'stopped'

1 Ответ

0 голосов
/ 21 ноября 2018

Я думаю, что проблема в том, что элемент вашего экрана недоступен, когда вы пытаетесь взаимодействовать с этим элементом.Если вы пытались использовать неявное ожидание, это не сработало для меня.

Вы можете использовать явное ожидание или Thread.sleep () .

Thread.sleep () не рекомендуется.

Вы можете использовать явное ожидание, используя следующий метод:

 public void ExplicitWait(MobileElement element,int timeOutInSeconds) {
        (new WebDriverWait(driver, timeOutInSeconds)).until(ExpectedConditions
                .visibilityOf(element));
    }
...