How to use platformVersion method in fMBT

Best Python code snippet using fMBT_python

test_android.py

Source:test_android.py Github

copy

Full Screen

1# coding=utf-82"""3@author:songmengyun4@file: test_android.py5@time: 2019/12/256"""7import pytest8import time9import logging10from appium import webdriver11from appium.webdriver.common.touch_action import TouchAction12from selenium.webdriver.support.wait import WebDriverWait13from appium.webdriver.connectiontype import ConnectionType14from collections import namedtuple15from poseidon.ui.mobile.android.init_driver import init_driver16'''17Android 6.0 18包名和界面名19设置:com.android.settings/.Settings20短信:com.android.messaging/.ui.conversationlist.ConversationListActivity21系统浏览器:com.android.browser/.BrowserActivity22联系人:com.android.contacts/.activities.PeopleActivity23英语口语700句:com.hj.kouyu700/com.hujiang.browser.JSWebViewActivity24cctalk登录页面:com.hujiang.cctalk/com.hujiang.browser.view.X5HJWebViewActivity25安智市场:cn.goapk.market/com.anzhi.market.ui.MainActivity26京东:com.jingdong.app.mall/.main.MainActivity27'''28Device = namedtuple('device_info', ['platformName', 'platformVersion', 'deviceName'])29App = namedtuple('app_info', ['appPackage', 'appActivity'])30class TestAndroid:31 @classmethod32 def setup_class(cls):33 """ setup any state specific to the execution of the given class (which usually contains tests).34 """35 logging.info('setup_class'.center(50, "*"))36 cls.device_and_6 = Device('Android', '6.0', '192.168.57.103:5555') # 需要连接平台名称,不区分大小写37 cls.app_setting = App('com.android.settings', '.Settings') # 平台的版本[5.4.3/5.4/5]38 cls.app_mis = App('com.android.messaging', '.ui.conversationlist.ConversationListActivity') # 设备的名称,随便写,但不能为空39 cls.app_anzi = App('cn.goapk.market', 'com.anzhi.market.ui.MainActivity') # 需要打开的应用名称,可通过 adb shell dumpsys window windows | grep mFocusedApp 获取40 cls.app_lock = App('com.android.settings', '.ChooseLockPattern') # 需要打开的界面名称41 @classmethod42 def teardown_class(cls):43 """ teardown any state that was previously setup with a call to setup_class.44 """45 logging.info('teardown_class'.center(50, "*"))46 def setup_method(self, method):47 """ 所有case初始化操作 """48 logging.info('setup_method'.center(50, '*'))49 desired_caps = {50 'platformName': 'Android',51 'deviceName': '192.168.57.103:5555',52 'platformVersion': '6.0',53 'appPackage': 'com.android.settings',54 'appActivity': '.Settings',55 'newCommandTimeout': '120',56 'noSign': True57 }58 self.driver = init_driver(desired_caps, command_executor='http://localhost:4723/wd/hub')59 def teardown_method(self, method):60 logging.info('teardown_method'.center(50, '*'))61 self.driver.quit()62 def test_start_activity(self):63 '''打开其他app: setup/teardown'''64 time.sleep(3)65 self.driver.start_activity(self.app_mis.appPackage, self.app_mis.appActivity)66 def test_get_package_activity(self):67 '''获取当前程序包名和界面名'''68 time.sleep(3)69 # 输出当前程序包名和界面名70 print(self.driver.current_package)71 print(self.driver.current_activity)72 # 切换到短信页面73 desired_caps = dict() # 初始化字典74 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写75 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]76 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空77 desired_caps['appPackage'] = self.app_mis.appPackage # 需要打开的应用名称,可通过 adb shell dumpsys window windows | grep mFocusedApp 获取78 desired_caps['appActivity'] = self.app_mis.appActivity # 需要打开的界面名称79 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)80 time.sleep(3)81 # 输出短信程序包名和界面名82 print(driver.current_package)83 print(driver.current_activity)84 def test_close_quit_app(self):85 '''关闭当前app/关闭驱动'''86 time.sleep(3)87 # self.driver.close_app()88 print(self.driver.current_package)89 print(self.driver.current_activity)90 print(self.driver.context)91 print(self.driver.contexts)92 print(self.driver.current_context)93 time.sleep(5)94 # self.driver.quit()95 # print(self.driver.current_package)96 # print(self.driver.current_activity)97 def test_install_uninstall_check(self):98 '''安装和卸载app'''99 desired_caps = dict() # 初始化字典100 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写101 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]102 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空103 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)104 time.sleep(3)105 # 判断安智市场是否已经安置106 if driver.is_app_installed(self.app_anzi.appPackage):107 driver.remove_app(self.app_anzi.appPackage)108 else:109 driver.install_app('/Users/songmengyun/Downloads/testing/appium/anzhishichang_6630.apk')110 time.sleep(3)111 driver.quit()112 def test_background(self):113 '''后台运行app'''114 desired_caps = dict() # 初始化字典115 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写116 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]117 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空118 desired_caps['appPackage'] = self.app_anzi.appPackage # 需要打开的应用名称119 desired_caps['appActivity'] = self.app_anzi.appActivity # 需要打开的界面名称120 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)121 time.sleep(3)122 # 置后台5s123 driver.background_app(5)124 time.sleep(3)125 driver.quit()126 def test_setting_element(self):127 '''定位1个元素:设置-点击放大镜-输入at-返回'''128 desired_caps = dict() # 初始化字典129 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写130 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]131 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空132 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称133 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称134 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)135 time.sleep(3)136 # 通过ID定位放大镜按钮,点击137 search_butoon = driver.find_element_by_id('com.android.settings:id/search')138 search_butoon.click()139 # 通过CLASS定位输入框,输入at140 search_box = driver.find_element_by_class_name('android.widget.EditText')141 search_box.send_keys('at')142 # 通过XPATH定位返回按钮,点击143 driver.find_element_by_xpath("//*[@content-desc='收起']").click()144 time.sleep(5)145 driver.quit()146 def test_setting_elements(self):147 '''定位1组元素:设置-输出所有id/title上text的内容'''148 desired_caps = dict() # 初始化字典149 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写150 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]151 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空152 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称153 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称154 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)155 time.sleep(3)156 # 通过ID获取resource-id为:com.android.settings:id/title的元素,并打印文字内容157 titles_ids = driver.find_elements_by_id('com.android.settings:id/title')158 for title in titles_ids:159 print(title.text)160 print('分割线'.center(100,'*'))161 # 通过CLASS获取class为:android.widget.TextView的元素,并打印文字内容162 titles_class = driver.find_elements_by_class_name('android.widget.TextView')163 for title in titles_class:164 print(title.text)165 print('分割线'.center(100,'*'))166 # 通过XPATH获取所有包含"设"的元素,并打印文字内容167 titles_xpath = driver.find_elements_by_xpath("//*[contains(@text,'设')]")168 for title in titles_xpath:169 print(title.text)170 time.sleep(5)171 driver.quit()172 def test_setting_implicitly_wait(self):173 '''元素等待:隐式等待'''174 desired_caps = dict() # 初始化字典175 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写176 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]177 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空178 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称179 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称180 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)181 # 隐式等待182 driver.implicitly_wait(3)183 print('---准备找返回进行点击')184 driver.find_element_by_xpath("//*[@content-desc='收起']").click()185 print('---点完了')186 # time.sleep(5)187 driver.quit()188 def test_setting_webdriverwait(self):189 '''元素等待:显示等待'''190 desired_caps = dict() # 初始化字典191 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写192 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]193 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空194 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称195 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称196 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)197 # 显示等待198 print('---准备找返回进行点击')199 wait = WebDriverWait(driver, 10, 1)200 back_button = wait.until(lambda x:x.find_element_by_xpath("//*[@content-desc='收起']"))201 # back_button = WebDriverWait(driver, 10, 1).until(lambda x:x.find_element_by_xpath("//*[@content-desc='收起']"))202 back_button.click()203 print('---点完了')204 driver.quit()205 def test_setting_click_element(self):206 '''元素等待:显示等待'''207 desired_caps = dict() # 初始化字典208 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写209 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]210 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空211 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称212 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称213 desired_caps['unicodeKeyboard'] = True # 输入框中文214 desired_caps['resetKeyboard'] = True215 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)216 eles = driver.find_elements_by_id('com.android.settings:id/title')217 for ele in eles: # 获取文本内容218 print(ele.text)219 print((ele.get_attribute('enabled')))220 print((ele.get_attribute('clickable')))221 print((ele.get_attribute('focusable')))222 print((ele.get_attribute('name'))) # 获取content-desc或text值223 print((ele.get_attribute('scrollable')))224 print((ele.get_attribute('className'))) # 获取class属性值225 print((ele.get_attribute('resourceId'))) # 获取resource-id属性值226 search_buttton = driver.find_element_by_id('com.android.settings:id/search')227 print('放大镜位置:', search_buttton.location) # 获取放大镜位置228 print(search_buttton.location['x'])229 print(search_buttton.location['y'])230 print('放大镜大小:',search_buttton.size) # 获取放大镜大小231 print(search_buttton.size['width'])232 print(search_buttton.size['height'])233 search_buttton.click() # 点击设置-放大镜按钮234 input_label = driver.find_element_by_class_name('android.widget.EditText')235 input_label.send_keys('hello') # 输入"hello"236 time.sleep(2) # 暂停2秒237 input_label.clear() # 清空所有文本238 time.sleep(3) # 暂停5秒239 input_label.send_keys('你好') # 输入"你好"240 time.sleep(3)241 driver.quit()242 def test_setting_swipe(self):243 '''滑动:模拟手指从(100,2000),滑动到(100,1000)'''244 desired_caps = dict() # 初始化字典245 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写246 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]247 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空248 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称249 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称250 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)251 # 模拟手指从(100,2000),滑动到(100,1000)252 # driver.swipe(100, 1500, 100, 1000)253 # driver.swipe(100, 1000, 100, 500)254 # driver.swipe(100, 500, 100, 0)255 # 从"更多"滑动到"语言和输入法"256 time.sleep(3)257 save_button = driver.find_element_by_xpath("//*[@text='更多']")258 more_button = driver.find_element_by_xpath("//*[@text='应用']")259 driver.scroll(save_button, more_button)260 # 从"更多"滑动到"打印"261 driver.drag_and_drop(more_button, save_button)262 time.sleep(20)263 driver.quit()264 def test_setting_touch_action_tap(self):265 '''手指轻敲操作:模拟手指对某个元素或坐标按下并快速抬起。比如固定点击100,100位置'''266 desired_caps = dict() # 初始化字典267 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写268 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]269 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空270 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称271 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称272 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)273 waln_button = driver.find_element_by_xpath("//*[@text='WLAN']")274 # 轻敲"WLAN"275 # 1.创建TouchAction对象 2.调用tap执行动作 3.使用perform执行动作276 TouchAction(driver).tap(waln_button).perform()277 time.sleep(3)278 TouchAction(driver).tap(x=200,y=200,count=2).perform()279 time.sleep(5)280 driver.quit()281 def test_setting_touch_action_press_and_release(self):282 '''按下和抬起操作:模拟手指一直按下,模拟手指抬起'''283 desired_caps = dict() # 初始化字典284 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写285 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]286 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空287 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称288 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称289 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)290 waln_button = driver.find_element_by_xpath("//*[@text='WLAN']")291 # 按下WLAN安装,2s后抬起292 TouchAction(driver).press(waln_button).perform()293 time.sleep(2)294 TouchAction(driver).press(waln_button).release().perform()295 time.sleep(5)296 driver.quit()297 def test_setting_touch_action_wait(self):298 '''等待操作:模拟手指等待,'''299 desired_caps = dict() # 初始化字典300 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写301 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]302 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空303 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称304 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称305 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)306 waln_button = driver.find_element_by_xpath("//*[@text='WLAN']")307 # 点击WLAN,等待5秒后,再按下wiredssid等待2s再抬起308 TouchAction(driver).tap(waln_button).perform()309 time.sleep(2)310 TouchAction(driver).press(x=228, y=408).wait(2000).release().perform()311 time.sleep(5)312 driver.quit()313 def test_setting_touch_action_long_press(self):314 '''长按操作:模拟手指对元素或坐标的长按操作'''315 desired_caps = dict() # 初始化字典316 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写317 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]318 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空319 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称320 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称321 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)322 waln_button = driver.find_element_by_xpath("//*[@text='WLAN']")323 # 使用坐标的形式点击WLAN,等待2s后,再长按下wiredssid的位置持续2s324 TouchAction(driver).tap(waln_button).perform()325 time.sleep(2)326 TouchAction(driver).long_press(x=228, y=408, duration=2000).release().perform()327 time.sleep(5)328 driver.quit()329 def test_setting_touch_action_move_to(self):330 '''移动操作:手势解锁,先按下再移动'''331 desired_caps = dict() # 初始化字典332 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写333 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]334 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空335 desired_caps['appPackage'] = self.app_lock.appPackage # 需要打开的应用名称336 desired_caps['appActivity'] = self.app_lock.appActivity # 需要打开的界面名称337 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)338 time.sleep(2)339 # 根据坐标位置滑动元素340 TouchAction(driver).press(x=179,y=630).move_to(x=539,y=630)\341 .move_to(x=901,y=630). move_to(x=901,y=989)\342 .move_to(x=542,y=989).move_to(x=901,y=1349).release().perform()343 time.sleep(5)344 driver.quit()345 def test_get_windows_size_and_screenshort(self):346 '''获取当前设备分辨率并截图'''347 desired_caps = dict() # 初始化字典348 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写349 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]350 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空351 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称352 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称353 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)354 # 获取当前设备的分辨率355 print(driver.get_window_size())356 # 手机截图357 driver.get_screenshot_as_file("screen.png")358 driver.quit()359 def test_get_set_network_connect(self):360 '''获取和设置当前网络'''361 desired_caps = dict() # 初始化字典362 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写363 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]364 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空365 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称366 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称367 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)368 # 获取当前网络类型并打印369 print(driver.network_connection)370 # 设置当前网络-飞行模式371 driver.set_network_connection(1)372 # 判断当前网络是不是流量: 如果是,设置为wifi373 if driver.network_connection == ConnectionType.DATA_ONLY:374 driver.set_network_connection(ConnectionType.WIFI_ONLY)375 if driver.network_connection == ConnectionType.AIRPLANE_MODE:376 driver.set_network_connection(ConnectionType.WIFI_ONLY)377 driver.quit()378 def test_press_keycode(self):379 '''发送键到设备:模拟按返回/home键等等操作,'''380 # 点击三次音量加键381 self.driver.press_keycode(24)382 self.driver.press_keycode(24)383 self.driver.press_keycode(24)384 # 再点击返回385 self.driver.press_keycode(4)386 # 再点击两次音量减387 self.driver.press_keycode(25)388 self.driver.press_keycode(25)389 def test_open_notifications(self):390 '''操作手机通知栏'''391 desired_caps = dict() # 初始化字典392 desired_caps['platformName'] = self.device_and_6.platformName # 需要连接平台名称,不区分大小写393 desired_caps['platformVersion'] = self.device_and_6.platformVersion # 平台的版本[5.4.3/5.4/5]394 desired_caps['deviceName'] = self.device_and_6.deviceName # 设备的名称,随便写,但不能为空395 desired_caps['appPackage'] = self.app_setting.appPackage # 需要打开的应用名称396 desired_caps['appActivity'] = self.app_setting.appActivity # 需要打开的界面名称397 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)398 # 打开通知栏399 driver.open_notifications()400 time.sleep(5)401 # 关闭通知栏,使用返回键402 driver.press_keycode(4)...

Full Screen

Full Screen

platform.py

Source:platform.py Github

copy

Full Screen

1# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# http://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13import re14import pkg_resources15from ebcli.objects.exceptions import EBCLIException16class PlatformVersion(object):17 class UnableToParseArnException(EBCLIException):18 pass19 ARN_PATTERN = re.compile(20 r'^arn:[^:]+:elasticbeanstalk:[^:]+:([^:]*):platform/([^/]+)/(\d+\.\d+\.\d+)$'21 )22 @classmethod23 def is_custom_platform_arn(cls, arn):24 if PlatformVersion.is_valid_arn(arn):25 return PlatformVersion(arn).account_id26 @classmethod27 def is_eb_managed_platform_arn(cls, arn):28 if PlatformVersion.is_valid_arn(arn):29 return not PlatformVersion(arn).account_id30 @classmethod31 def is_valid_arn(cls, arn):32 if not isinstance(arn, str) and not isinstance(arn, bytes):33 return False34 return PlatformVersion.ARN_PATTERN.search(arn)35 @classmethod36 def arn_to_platform(cls, arn):37 match = PlatformVersion.ARN_PATTERN.search(arn)38 if not match:39 raise PlatformVersion.UnableToParseArnException("Unable to parse arn '{}'".format(arn))40 account_id, platform_name, platform_version = match.group(1, 2, 3)41 return account_id, platform_name, platform_version42 @classmethod43 def get_platform_version(cls, arn):44 _, _, platform_version = PlatformVersion.arn_to_platform(arn)45 return platform_version46 @classmethod47 def get_platform_name(cls, arn):48 _, platform_name, _ = PlatformVersion.arn_to_platform(arn)49 return platform_name50 @classmethod51 def get_region_from_platform_arn(cls, arn):52 if cls.is_eb_managed_platform_arn(arn):53 split_string = arn.split(':')54 return split_string[3]55 @classmethod56 def match_with_complete_arn(57 cls,58 platforms,59 input_platform_name60 ):61 for platform in platforms:62 if platform == input_platform_name:63 return PlatformVersion(platform)64 @classmethod65 def match_with_platform_name(66 cls,67 custom_platforms,68 input_platform_name69 ):70 for custom_platform in custom_platforms:71 if PlatformVersion.get_platform_name(custom_platform) == input_platform_name:72 return PlatformVersion(custom_platform)73 def __init__(self, arn):74 self.arn = arn75 account_id, platform_name, platform_version = PlatformVersion.arn_to_platform(arn)76 # For the sake of the CLI a version is the same thing as an ARN77 self.version = self.arn78 self.name = arn79 self.account_id = account_id80 self.platform_version = platform_version81 self.platform_shorthand = platform_name82 def __str__(self):83 return self.version84 def __eq__(self, other):85 if not isinstance(other, PlatformVersion):86 return False87 return self.version == other.version88 def __ne__(self, other):89 return not self.__eq__(other)90 @property91 def has_healthd_group_version_2_support(self):92 if PlatformVersion.is_custom_platform_arn(self.name):93 return False94 return pkg_resources.parse_version(self.platform_version) \95 >= pkg_resources.parse_version('2.0.10')96 @property97 def has_healthd_support(self):98 return pkg_resources.parse_version(self.platform_version) \...

Full Screen

Full Screen

device_db.py

Source:device_db.py Github

copy

Full Screen

1'''2This file is used as a database of known devices.3In the future this may need to be changed to an actual database4but at the time of creation this was sufficient5'''6devices = [7 {8 'platformName': 'Android',9 'platformVersion': '6.0.1',10 'deviceName': 'Galaxy S5',11 'udid': 'ca13ba30',12 },13 {14 'platformName': 'Android',15 'platformVersion': '6.0.1',16 'deviceName': 'Galaxy S7 Edge',17 'udid': 'b85d1213'18 },19 {20 'platformName': 'Android',21 'platformVersion': '6.0.1',22 'deviceName': 'Galaxy S6 Edge Plus',23 'udid': '0715f763fb412738'24 },25 {26 'platformName': 'Android',27 'platformVersion': '6.0.1',28 'deviceName': 'Galaxy S6',29 'udid': '06157df6a58b4c33',30 },31 {32 'platformName': 'Android',33 'platformVersion': '4.4.4',34 'deviceName': 'Nexus 5',35 'udid': '04d08f25344bd15b'36 },37 {38 'platformName': 'Android',39 'platformVersion': '7.0',40 'deviceName': 'Galaxy S7',41 'udid': 'ebacbe57',42 },43 {44 'platformName': 'Android',45 'platformVersion': '6.0.1',46 'deviceName': 'ZTE',47 'udid': '3487a1c5'48 },49 {50 'platformName': 'Android',51 'platformVersion': '5.0.2',52 'deviceName': 'Galaxy A5',53 'udid': 'VCP7N15A20006622'54 },55 {56 'platformName': 'Android',57 'platformVersion': '5.1',58 'deviceName': 'Huawei',59 'udid': 'fdb354b1'60 },61 {62 'platformName': 'Android',63 'platformVersion': '4.4.2',64 'deviceName': 'LG G3',65 'udid': 'LGD850caeb2ee'66 }67]68browsers = ('Chrome', '')69test_android = {70 'platformName': 'Android',71 'deviceName': 'Android Emulator'72 }73emulator_version = (74 '4.4',75 '5.0',76 '5.1',77 '6.0',78 '7.0',79 '7.1.1'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful