本文整理汇总了Python中appium.webdriver.Remote方法的典型用法代码示例。如果您正苦于以下问题:Python webdriver.Remote方法的具体用法?Python webdriver.Remote怎么用?Python webdriver.Remote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appium.webdriver
的用法示例。
在下文中一共展示了webdriver.Remote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_browserstack
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def run_browserstack(self,os_name,os_version,browser,browser_version,remote_project_name,remote_build_name):
"Run the test in browser stack when remote flag is 'Y'"
#Get the browser stack credentials from browser stack credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['os'] = os_name
desired_capabilities['os_version'] = os_version
desired_capabilities['browser_version'] = browser_version
if remote_project_name is not None:
desired_capabilities['project'] = remote_project_name
if remote_build_name is not None:
desired_capabilities['build'] = remote_build_name+"_"+str(datetime.now().strftime("%c"))
return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browserstack.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
desired_capabilities=desired_capabilities)
示例2: run_sauce_lab
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def run_sauce_lab(self,os_name,os_version,browser,browser_version):
"Run the test in sauce labs when remote flag is 'Y'"
#Get the sauce labs credentials from sauce.credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = os_name + ' '+os_version
return webdriver.Remote(command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD),
desired_capabilities= desired_capabilities)
示例3: run_browserstack
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def run_browserstack(self,os_name,os_version,browser,browser_version,remote_project_name,remote_build_name):
"Run the test in browser stack when remote flag is 'Y'"
#Get the browser stack credentials from browser stack credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['os'] = os_name
desired_capabilities['os_version'] = os_version
desired_capabilities['browser_version'] = browser_version
if remote_project_name is not None:
desired_capabilities['project'] = remote_project_name
if remote_build_name is not None:
desired_capabilities['build'] = remote_build_name+"_"+str(datetime.now().strftime("%c"))
return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browserstack.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
desired_capabilities=desired_capabilities)
示例4: run_sauce_lab
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def run_sauce_lab(self,os_name,os_version,browser,browser_version):
"Run the test in sauce labs when remote flag is 'Y'"
#Get the sauce labs credentials from sauce.credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = os_name + ' '+os_version
return webdriver.Remote(command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD),
desired_capabilities= desired_capabilities)
示例5: test_all_sessions
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def test_all_sessions(self) -> None:
port = get_available_from_port_range(8200, 8300)
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
desired_caps['deviceName'] = 'iPhone Xs Max'
desired_caps['wdaLocalPort'] = port
class session_counts_is_two:
TIMEOUT = 10
def __call__(self, driver: 'WebDriver') -> bool:
return len(driver.all_sessions) == 2
driver2 = None
try:
driver2 = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
WebDriverWait(
driver2, session_counts_is_two.TIMEOUT).until(session_counts_is_two())
assert len(self.driver.all_sessions) == 2
finally:
if driver2 is not None:
driver2.quit()
示例6: __init__
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def __init__(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '88CKBM622PAM'
desired_caps['appPackage'] = 'com.tencent.mm'
desired_caps['appActivity'] = '.ui.LauncherUI'
# 定义在朋友圈的时候滑动位置
self.start_x = 300
self.start_y = 800
self.end_x = 300
self.end_y = 300
# 启动微信
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# 设置等待
self.wait = WebDriverWait(self.driver, 300)
print('微信启动...')
示例7: __init__
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def __init__(self, addr=None):
if not addr:
addr = '127.0.0.1'
self.url = 'http://%s:4723/wd/hub' % addr
self.driver = webdriver.Remote(
command_executor=self.url,
desired_capabilities={
'platformName': 'iOS',
# after appium 1.2.0, deviceName is required
'deviceName': 'ios device',
'autoLaunch': False
}
)
self._scale = None
self.start()
self._init()
示例8: open_application
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def open_application(self, remote_url, alias=None, **kwargs):
"""Opens a new application to given Appium server.
Capabilities of appium server, Android and iOS,
Please check https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/server-args.md
| *Option* | *Man.* | *Description* |
| remote_url | Yes | Appium server url |
| alias | no | alias |
Examples:
| Open Application | http://localhost:4723/wd/hub | alias=Myapp1 | platformName=iOS | platformVersion=7.0 | deviceName='iPhone Simulator' | app=your.app |
| Open Application | http://localhost:4723/wd/hub | platformName=Android | platformVersion=4.2.2 | deviceName=192.168.56.101:5555 | app=${CURDIR}/demoapp/OrangeDemoApp.apk | appPackage=com.netease.qa.orangedemo | appActivity=MainActivity |
"""
desired_caps = kwargs
application = webdriver.Remote(str(remote_url), desired_caps)
self._debug('Opened application with session id %s' % application.session_id)
return self._cache.register(application, alias)
示例9: __init__
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def __init__(self):
"""
初始化
"""
# 驱动配置
self.desired_caps = {
'platformName': PLATFORM,
'deviceName': DEVICE_NAME,
'appPackage': WECHAT_PACKAGE,
'appActivity': WECHAT_ACTIVITY,
'noReset': True,
"automationName": "Uiautomator2"
}
self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)
self.wait = WebDriverWait(self.driver, TIMEOUT)
self.client = MongoClient(MONGO_URL)
self.db = self.client[WECHAT_XHS_MONGO_DB]
self.collection = self.db[WECHAT_XHS_MONGO_COLLECTION]
# 处理器
self.processor = Processor()
示例10: __init__
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def __init__(self):
"""
初始化
"""
# 驱动配置
self.desired_caps = {
'platformName': PLATFORM,
'deviceName': DEVICE_NAME,
'appPackage': XHS_PACKAGE,
'appActivity': XHS_ACTIVITY,
'noReset': True,
"automationName": "Uiautomator2"
}
global collection
self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)
self.wait = WebDriverWait(self.driver, TIMEOUT)
self.client = MongoClient(MONGO_URL)
self.db = self.client[XHS_MONGO_DB]
self.collection = self.db[XHS_MONGO_COLLECTION]
self.processor = Processor()
示例11: start_appium
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def start_appium(self):
"""
启动driver
:return:
"""
number_of_starts = 0
while number_of_starts < 6:
try:
self.driver = webdriver.Remote(
'http://127.0.0.1:%s/wd/hub' %
self.__get_appium_port(), self.device_l)
U.Logging.debug('appium start %s success' % self.device)
return self.driver
except Exception as e:
number_of_starts += 1
U.Logging.error('Failed to start appium :{}'.format(e))
U.Logging.error(
'Try restarting the appium :{},Trying the {} frequency'.format(self.device, number_of_starts))
U.sleep(5)
if number_of_starts > 5:
U.Logging.error('Can not start appium, the program exits')
exit()
示例12: get_android_driver
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def get_android_driver(self, sno):
desired_caps = self.get_desired_capabilities(sno)
self.before_create_driver(desired_caps['udid'])
port = self.get_appium_port(desired_caps["udid"])
if not self.is_port_used(port):
self.log4py.debug("设备号[{}]对应的appium服务没有启动".format(desired_caps['udid']))
return None
url = 'http://127.0.0.1:%s/wd/hub' % (port.strip())
self.log4py.debug(url)
self.log4py.debug(desired_caps)
num = 0
while num <= 5:
try:
driver = webdriver.Remote(url, desired_caps)
except urllib2.URLError as e:
self.log4py.error("连接appium服务,实例化driver时出错,尝试重连...({})".format(num))
num = num + 1
continue
if self.run_data["wait_activity"] is not None:
driver.wait_activity(self.run_data["wait_activity"], 10)
else:
driver.implicitly_wait(10)
self.log4py.info("webdriver连接信息:{}:{}".format(url, str(desired_caps)))
return driver
return None
示例13: __init__
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def __init__(self):
self.connect()
self.desired_caps = {
"platformName": caps["platformname"],
"platformVersion": caps["platformversion"],
"automationName": caps["automationname"],
"unicodeKeyboard": caps["unicodekeyboard"],
"resetKeyboard": caps["resetkeyboard"],
"noReset": caps["noreset"],
'newCommandTimeout': 800,
"deviceName": caps["devicename"],
"uuid": caps["uuid"],
"appPackage": caps["apppackage"],
"appActivity": caps["appactivity"]
}
logger.info('打开 appium 服务,正在配置...')
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
self.wait = WebDriverWait(self.driver, 10)
self.size = self.driver.get_window_size()
示例14: setUp
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9'
desired_caps['deviceName'] = 'emulator-5554'
# Returns abs path relative to this file and not cwd
# desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'apps/whatsapp.apk'))
desired_caps['appPackage'] = 'com.android.contacts'
desired_caps['appActivity'] = '.activities.PeopleActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
#self.emulator_name = 'pixel_1'
#self.mobile_number = '+91 78386 67436'
#self.message_body = 'Hello There!'
self.emulator_name = self.emulator_name
self.mobile_number = self.mobile_number
# self.action = action
示例15: __init__
# 需要导入模块: from appium import webdriver [as 别名]
# 或者: from appium.webdriver import Remote [as 别名]
def __init__(self):
self.caps = {
'automationName': DRIVER,
'platformName': PLATFORM,
'deviceName': DEVICE_NAME,
'appPackage': APP_PACKAGE,
'appActivity': APP_ACTIVITY,
'platformVersion': ANDROID_VERSION,
'autoGrantPermissions': AUTO_GRANT_PERMISSIONS,
'unicodeKeyboard': True,
'resetKeyboard': True
}
self.driver = webdriver.Remote(DRIVER_SERVER, self.caps)
self.wait = WebDriverWait(self.driver, TIMEOUT)