Проблема : вместо тестируемого сайта во встроенном браузере открывается страница Google …
Использую следующий код:
class ChromeTests(unittest.TestCase):
def setUp(self):
desired_caps ={}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.0.2'
desired_caps['deviceName'] = 'LGD724e6026273'
desired_caps['browserName'] = 'Browser'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def test_find_single_element(self):
driver = self.driver
base_url = "http://192.168.53.7"
driver.get(base_url)
В итоге запускается браузер со страницей гугл.
При этом с мобильным Chrome (desired_caps[‘browserName’] = ‘Chrome’) работает отлично, открывается именно мой сайт.
Пробовал изменить в настройках браузера домашнюю страницу - после запуска теста он ее снова устанавливает в Google …
Телефон LG D724
Android SDK v1.3.1
Appium v1.4.0.0
Webdriver v2.47.1
Python v3.4.3
Windows7/Ubuntu 14.04
Karamba
(Константин)
26.Август.2015 13:07:22
#2
Appium работает только с мобильным хромом, если вы хотите автоматизировать мобильный сайт
А как же?
Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in ‘Browser’ app on Android)
http://appium.io/introduction.html?lang=en
Karamba
(Константин)
27.Август.2015 08:25:10
#4
Так, а почему мобильный хром не устраивает?
Аппиум может поддерживать только браузеры на движке chromium, ну а производители телефонов в свои стоковые браузеры могут всякого напихать.
Это все равно, что вопрошать почему selenium некорректно работает со всякими поделками типа яндекс.браузера, comodo dragon и т.п. )
Вопрошаю, потому что хочу разобраться)
И т.к. Appium пишет, что может работать со встроенным браузером, хотел запустить свои тесты и на нем. К тому же поведение моего подопытного сайта отличалось в мобильном хроме и во встроенном браузере. Сайт почти целиком на JS написан.
В любом случае спасибо за прояснение моей ситуации.
Karamba
(Константин)
27.Август.2015 09:04:46
#6
Вот issue по этому поводу, там Джонатан в принципе тоже самое и объясняет
opened 03:52AM - 09 Feb 15 UTC
closed 04:03PM - 07 Apr 15 UTC
Bug
Android
Android real device 4.4.4 (Samsung device)
Appium 1.3.4
When execute with capab… ility "browserName": "Browser" to test on Android default Browser the ChromeDriver log is: chrome is not reachable and Appium log is: Session can not create ...
Here is Appium log:
[36minfo[39m: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
[36minfo[39m: Appium REST http interface listener started on 0.0.0.0:4723
[36minfo[39m: [debug] Non-default server args: {"udid":"7b70e0b7","fullReset":true,"defaultCommandTimeout":3600,"tmpDir":"/Users/admin/Appium_Temp"}
[36minfo[39m: Console LogLevel: debug
[36minfo[39m: [37m-->[39m [37mGET[39m [37m/wd/hub/status[39m [90m{}[39m
[36minfo[39m: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.4","revision":"c8c79a85fbd6870cd6fc3d66d038a115ebe22efe"}}}
[36minfo[39m: [37m<-- GET /wd/hub/status [39m[32m200[39m[90m 9.050 ms - 104[39m [90m{"status":0,"value":{"build":{"version":"1.3.4","revision":"c8c79a85fbd6870cd6fc3d66d038a115ebe22efe"}}}[39m
[36minfo[39m: [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m [90m{"desiredCapabilities":{"deviceName":"SM-G530H","platformName":"Android","browserName":"Browser"}}[39m
[36minfo[39m: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
[36minfo[39m: Set mode: Proxying straight through to Chromedriver
[36minfo[39m: [debug] Looks like we want chrome on android
[36minfo[39m: [debug] Creating new appium session 42566fb2-6473-4b53-8529-4a75166ab52f
[36minfo[39m: [debug] Using fast reset? false
[36minfo[39m: [debug] Preparing device for session
[36minfo[39m: [debug] Not checking whether app is present since we are assuming it's already on the device
[36minfo[39m: [debug] Checking whether adb is present
[36minfo[39m: [debug] Using adb from /liemdang/Applications/android_sdk/platform-tools/adb
[36minfo[39m: Retrieving device
[36minfo[39m: [debug] Trying to find a connected android device
[36minfo[39m: [debug] Getting connected devices...
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb devices
[36minfo[39m: [debug] 2 device(s) connected
[36minfo[39m: Found device 7b70e0b7
[36minfo[39m: [debug] Setting device id to 7b70e0b7
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 wait-for-device
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 shell "echo 'ready'"
[36minfo[39m: [debug] Starting logcat capture
[36minfo[39m: [debug] Pushing unlock helper app to device...
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 install "/usr/local/lib/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 shell "dumpsys window"
[36minfo[39m: [debug] Screen already unlocked, continuing.
[36minfo[39m: [debug] Forwarding system:4724 to device:4724
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 forward tcp:4724 tcp:4724
[36minfo[39m: [debug] Pushing appium bootstrap to device...
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 push "/usr/local/lib/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar" /data/local/tmp/
[36minfo[39m: Starting App
[36minfo[39m: [debug] Attempting to kill all 'uiautomator' processes
[36minfo[39m: [debug] Getting all processes with 'uiautomator'
[36minfo[39m: [debug] executing cmd: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 shell "ps 'uiautomator'"
[36minfo[39m: [debug] No matching processes found
[36minfo[39m: [debug] Running bootstrap
[36minfo[39m: [debug] spawning: /liemdang/Applications/android_sdk/platform-tools/adb -s 7b70e0b7 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1[39m
[36minfo[39m: [debug] [90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1[39m
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Loading json...
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
[36minfo[39m: [debug] Pushing command to appium work queue: ["getDataDir",{}]
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Client connected
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data\/local\/tmp","status":0}
[36minfo[39m: [debug] dataDir set to: /data/local/tmp
[36minfo[39m: [debug] Creating Chrome session
[36minfo[39m: [debug] Set chromedriver binary as: /usr/local/lib/node_modules/appium/build/chromedriver/mac/chromedriver
[36minfo[39m: [debug] Ensuring Chromedriver exists
[36minfo[39m: [debug] Killing any old chromedrivers, running: ps -ef | grep /usr/local/lib/node_modules/appium/build/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515(\s.*)\?$' | awk '{ print $2 }' | xargs kill -15
[36minfo[39m: [debug] Successfully cleaned up old chromedrivers
[36minfo[39m: [debug] Spawning chromedriver with: /usr/local/lib/node_modules/appium/build/chromedriver/mac/chromedriver
[36minfo[39m: [debug] [CHROMEDRIVER] Starting ChromeDriver (v2.10.267517) on port 9515
Only local connections are allowed.
[36minfo[39m: [debug] Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session","method":"POST","json":{"sessionId":null,"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.browser","androidActivity":"com.android.browser.BrowserActivity","androidDeviceSerial":"7b70e0b7"}}}}
[36minfo[39m: [debug] Cleaning up appium session
[36minfo[39m: [debug] Error: Did not get session redirect from Chromedriver
at null.<anonymous> (/usr/local/lib/node_modules/appium/lib/devices/android/chromedriver.js:222:12)
at Request._callback (/usr/local/lib/node_modules/appium/lib/devices/common.js:121:5)
at Request.self.callback (/usr/local/lib/node_modules/appium/node_modules/request/request.js:121:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/request/request.js:985:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/request/request.js:936:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickDomainCallback (node.js:486:13)
[36minfo[39m: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Did not get session redirect from Chromedriver)","origValue":"Did not get session redirect from Chromedriver"},"sessionId":null}
[36minfo[39m: [37m<-- POST /wd/hub/session [39m[31m500[39m[90m 66590.961 ms - 214[39m [90m[39m
Executing tests on Android default Browser for real device is not supported right?
Do you have any ideas or plans to support this?
Полезный issue. При этом у автора тест работал в эмуляторе.
В моем случае, в эмуляторе Android проблема с home page полностью повторилась.
Karamba
(Константин)
27.Август.2015 12:16:44
#8
Просто со стоковыми браузерами, от разных производителей неоднозначная ситуация. Поэтому, ИМХО, лучше сконцентрироваться на мобильном хроме. Во всяком случае его поведение, в большинстве случаев, будет одинаковым на разных девайсах. Не будете же вы всегда гонять свои тесты только на LG
1 лайк
Согласен. Наверняка так и поступлю. Но т.к. только начал работать с Appium хотел докопаться до сути проблемы, особенно учитывая, что в эмуляторе та же ситуация.