51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 3080|回复: 0
打印 上一主题 下一主题

[Appium] Appium自动化测试遇到的chromedriver/chrome坑

[复制链接]
  • TA的每日心情
    无聊
    1 小时前
  • 签到天数: 936 天

    连续签到: 3 天

    [LV.10]测试总司令

    跳转到指定楼层
    1#
    发表于 2020-11-3 09:58:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    一、前言

      app的webview自动化是依赖于chromedriver的,并且每个app的webview版本号都不太一样,这就导致了每次都需要重新去下载对应的chromedriver版本。如何根据当前的webdriver版本去匹配对应chromedriver版本,这是一个难题。
      根据官方文档翻译过来看,版本不匹配的话一般会报错:
    1. An unknown server-side error occurred while processing the command.

    2.   Original error: unknown error: Chrome version must be >= 55.0.2883.0
    复制代码
    二、Chrome driver启动

      用chrome浏览器运行自动化测试用例时,如果报这样的错误
    1. selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing value
    复制代码
    可以这样来解决:指定chromedriver.exe驱动绝对路径
      driver = webdriver.Chrome(r'e:\xxx\chromedriver.exe')
      三、常遇错误
      我们在使用native和h5混合的应用程序测试时,可能会遇到报错
    1. E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py:1031:

    2.   UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension。

    3.   "type. It should end with a `.png` extension", UserWarning)

    4.   ..['NATIVE_APP', 'WEBVIEW_chrome', 'WEBVIEW_com.android.browser']

    5.   NATIVE_APP

    6.   Doctor my center Test Over.

    7.   E

    8.   =====================================================

    9.   ERROR: test_e_AboutContact (__main__.center)

    10.   ----------------------------------------------------------------------

    11.   Traceback (most recent call last):

    12.   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')

    13.   File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\appium\webdriver\switch_to.py", line 31, in context

    14.   self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})

    15.   File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute

    16.   self.error_handler.check_response(response)

    17.   File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response raise wde

    18.   File"E:\ProgramFiles(x86)\Python\Python37\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response

    19.   super(MobileErrorHandler, self).check_response(response)

    20.   File "E:\Program Files (x86)\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response

    21.   raise exception_class(message, screen, stacktrace)

    22.   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.

    23.   ----------------------------------------------------------------------

    24.   Ran 3 tests in 66.001s

    25.   FAILED (errors=1)

    26.   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。



    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

    x
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-4-24 10:58 , Processed in 0.062831 second(s), 24 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表