Reputation: 3
When running the following code to automate opening chrome browser on my android device I see the following error
from __future__ import print_function
import sys
import time
from appium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
DC_USER_NAME = 'admin'
DC_API_KEY = ''
DC_DEVICE_ID = 'd6b54c70-fc07-49a4-9737-11daee82f19c'
DC_HOST = 'localhost'
APP_PACKAGE = ''
APP_ACTIVITY = ''
AUTOMATION_NAME = 'UiAutomator2'
desired_caps = DesiredCapabilities.CHROME
caps = {
'gigafox:UserName' : DC_USER_NAME,
'gigafox:ApiKey' : DC_API_KEY,
'gigafox:Device' : DC_DEVICE_ID,
'gigafox:application' : '',
'newCommandTimeout' : 1000,
#'appPackage' :APP_PACKAGE,
#'appActivity' :APP_ACTIVITY,
'platformName' : 'Android',
'browserName' : 'Chrome',
'automationName' : AUTOMATION_NAME
}
url = 'http://{0}/Appium'.format(DC_HOST)
print('loading driver')
driver = webdriver.Remote(url, caps)
print('connected.')
driver.Quit()
Error return
Automation Scripts % python3 connectAndroid.py loading driver Traceback (most recent call last): File "/Users/kris/Desktop/Github/Automation Scripts/connectAndroid.py", line 51, in driver = webdriver.Remote(url, caps) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/appium/webdriver/webdriver.py", line 244, in init self._update_command_executor(keep_alive=keep_alive) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/appium/webdriver/webdriver.py", line 285, in _update_command_executor assert self.caps, 'Driver capabilities must be defined' AssertionError: Driver capabilities must be defined
My device wakes up and connects but when the browser is opened I see an error on the screen and the above is output in terminal
Upvotes: 0
Views: 438
Reputation: 347
I think you should try adding the following caps:
{
"appium:deviceName": "#find serial nr of phone from running adb devices on cmd",
"platformName": "Android",
"appium:app": "C:\\Users\\#full path of the apk you want to open",
"appium:udid": "#repeat serial nr of phone"
}
Upvotes: 0