appium處理app與web頁面的轉換


 
測微信頁面的時候使用谷歌app,進入微信頁面的鏈接
def setUp(self):
print("set up env for android testing...")
self.desired_caps = {
'platformName': 'Android',
'platformVersion': '5.1.1',
'deviceName': 'KIW-TL00',
'browserName': '',
'appPackage': 'com.android.chrome',
'appActivity': 'org.chromium.chrome.browser.ChromeTabbedActivity',
'unicodeKeyboard': 'true',
'resetKeyboard': 'true'
}
self.driver = webdriver.Remote(command_executor='http://localhost:4723/wd/hub', desired_capabilities=self.desired_caps)
self.driver.get('http://release.thy360.com/o2o_weixin/index.html#/tab/platformHome')
self.driver.implicitly_wait(30)
此時已經從app中進入了微信鏈接的web頁面,接下來的定位xpath都是在web頁面上進行的,所以需要轉換到web頁面
使用語句
self.driver.switch_to.context('WEBVIEW_1')
 
 
self.driver.switch_to.context()
 如果是從App轉到web的話()填"WEBVIEW_1",
如果web轉到App的話填"NATIVE_APP"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM