TA的每日心情 | 无聊 13 小时前 |
---|
签到天数: 1050 天 连续签到: 1 天 [LV.10]测试总司令
|
一、前言
app的webview自动化是依赖于chromedriver的,并且每个app的webview版本号都不太一样,这就导致了每次都需要重新去下载对应的chromedriver版本。如何根据当前的webdriver版本去匹配对应chromedriver版本,这是一个难题。
根据官方文档翻译过来看,版本不匹配的话一般会报错:
- An unknown server-side error occurred while processing the command.
- Original error: unknown error: Chrome version must be >= 55.0.2883.0
复制代码 二、Chrome driver启动
用chrome浏览器运行自动化测试用例时,如果报这样的错误
- selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing value
复制代码 可以这样来解决:指定chromedriver.exe驱动绝对路径
driver = webdriver.Chrome(r'e:\xxx\chromedriver.exe')
三、常遇错误
我们在使用native和h5混合的应用程序测试时,可能会遇到报错
- E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py:1031:
- UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension。
- "type. It should end with a `.png` extension", UserWarning)
- ..['NATIVE_APP', 'WEBVIEW_chrome', 'WEBVIEW_com.android.browser']
- NATIVE_APP
- Doctor my center Test Over.
- E
- =====================================================
- ERROR: test_e_AboutContact (__main__.center)
- ----------------------------------------------------------------------
- Traceback (most recent call last):
- File "E:/ATS/TCyDoctorNew/test_case/test_dir/test_4doctormycenter.py", line 371, in test_e_AboutChengyiContact driver.switch_to.context('WEBVIEW_com.android.browser')
- File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\appium\webdriver\switch_to.py", line 31, in context
- self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})
- File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
- self.error_handler.check_response(response)
- File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response raise wde
- File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response
- super(MobileErrorHandler, self).check_response(response)
- File "E:\Program Files (x86)\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
- raise exception_class(message, screen, stacktrace)
- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome '55.0.2883'. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more details.
- ----------------------------------------------------------------------
- Ran 3 tests in 66.001s
- FAILED (errors=1)
- Process finished with exit code 0
复制代码 我们来看报错信息,第一个是warning,是指截图的格式最好是png,这个与本文无关我们先忽略,关键看第二个错误,它主要缘于“No Chromedriver found that can automate Chrome '55.0.2883”,在appium日志里也能看到详情
四、了解chromedriver
通过管理Chromedriver, Appium支持安卓网页和支持谷歌的混合app的自动化。通过npm package安装的总是绑定最新的chromedriver。
|
|