方法一:
Open Application http://127.0.0.1:4723/wd/hub platformName=Android platformVersion=${platformVersion} deviceName= ${deviceName} browserName=Chrome unicodeKeyboard=true resetKeyboard=true chromedriverExecutableDir=D:/WanleAutoTestForH5/ChromeDrivers/78.0.3904.70
#如果出现权限弹框则切换至原生状态,接受弹框即可
${contexts} Get Contexts
Switch To Context NATIVE_APP
Run Keyword And Ignore Error click element xpath=(//android.widget.Button)[2]
方法二:作为原生软件启动后切换至webview_chrome,原生启动的好处是可以设置noReset=true而缓存一些
权限设置
Open Application http://127.0.0.1:4723/wd/hub platformName=Android platformVersion=${platformVersion} deviceName=${deviceName} appPackage=com.android.chrome appActivity=com.google.android.apps.chrome.Main unicodeKeyboard=true resetKeyboard=true chromedriverExecutableDir=D:/WanleAutoTestForH5/ChromeDrivers/78.0.3904.70 recreateChromeDriverSessions=true noReset=true
${contexts} get contexts
${status} Run Keyword And Return Status Page Should Contain Element xpath=(//android.widget.Button[@text="允许"])
run keyword if '${status}'=='True' click element xpath=(//android.widget.Button[@text="允许"])
click element xpath=(//android.widget.EditText)[1]
input text xpath=(//android.widget.EditText)[1] ${url}
Press Keycode 66
${contexts} get contexts
switch to context WEBVIEW_chrome