• 测试学习过程出错总结


    1、在使用unittest过程出错: 

      test_suite.py:None       <frozen importlib._bootstrap>:971: in _find_and_load     in _importtestmodule

    大体翻译:在查找和加载过程中”冻结的引用库“

    我的问题原因:应该是由于我自己写的py文件中的test模块与python中的文件重名了。

    解决:只需要将test开头的文件名字改一下就可以了,一定注意同时将应用该文件的代码改一下。

    2、在使用selenium的过程出现错误:

      selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 83

    大体翻译:这个chromDriver的版本不支持chrome83版本。

    一段时间没有用selenium,再次使用,出现了这个问题,网上查到,可能因为chrome驱动器和chrome浏览器的版本号不匹配

    确认错误:

    1)查看chrome的版本号

     方法一:在浏览器中输入    chrome://version/

     方法二:

      依次执行下列的流程

                       

      之后点击设置

        

       之后就看到chrome的版本

        

     2)查看selenium的版本

    我的selenium安装在anaconda的虚拟环境中,打开cmd命令行

    然后,输入:activate 虚拟环境名字

    最后输入下列代码:

    pip show selenium

    可以看到:

    3)下载对应版本并安装

    下载自己的chrome版本对应的driver:http://chromedriver.storage.googleapis.com/index.html

     

     解压之后会看到:

    最后,将.exe文件放到虚拟环境中的script文件夹下面,就可以使用了。测试一下:

    from selenium import webdriver
    
    browser = webdriver.Chrome()   # 声明一个浏览器对象
    
    browser.get('http://www.baidu.com')    # 在chrome浏览器中打开url
    input = browser.find_element_by_id('kw')     # 通过id定位到chrome
    input.send_keys('python')     # 在输入框中输入关键字
    

    成功打开浏览器。

    另外一种方法:复制chromedriver.exe文件的路径并加入到电脑的环境变量中去。可以参考:https://blog.csdn.net/weixin_43545225/article/details/107042347

    我的python环境使用的是anaconda里面的虚拟环境,尝试了这种方法,但是不成功,不知道为什么。有大神知道吗?留在这里,以后在回顾吧。

    4)为了可以一直使用chromedriver版本,可以设置chrome不更新,见链接:https://jingyan.baidu.com/article/f3ad7d0f51c6bf09c3345bb0.html 

    3、安装jsonpath出错

    Collecting package metadata (repodata.json): done
    Solving environment: failed with initial frozen solve. Retrying with flexible solve.

    PackagesNotFoundError: The following packages are not available from current channels:

    - //github.com/json-path/jsonpath.git

    Current channels:

    - https://repo.anaconda.com/pkgs/main/win-64
    - https://repo.anaconda.com/pkgs/main/noarch
    - https://repo.anaconda.com/pkgs/r/win-64
    - https://repo.anaconda.com/pkgs/r/noarch
    - https://repo.anaconda.com/pkgs/msys2/win-64
    - https://repo.anaconda.com/pkgs/msys2/noarch

    To search for alternate channels that may provide the conda package you're
    looking for, navigate to

    https://anaconda.org

    and use the search bar at the top of the page.

    解决办法:

    首先输入 anaconda search -t conda jsonpath,找到可下载的版本

     然后输入conda install -c https://conda.anaconda.org/alcibiade jsonpath-rw

     注意:alcibiade jsonpath-rw之间没有/

    待总结。。。。。。

  • 相关阅读:
    PHP 包含文件路径问题
    PHP显示今天、今月、上月、今年的起点/终点时间戳
    PHP Web基础教程
    php如何生成随机密码的几种方法
    You don't have permission to access /~whpc on this server.
    linux 网络 PING IP可以通,ping域名ping不通
    CPU : 二级缓存容量
    简单建立个人WEB网站
    MKL程序编译与连接:Lapack篇
    ldd命令原理与使用
  • 原文地址:https://www.cnblogs.com/liliwang/p/13848641.html
Copyright © 2020-2023  润新知