zoukankan      html  css  js  c++  java
  • Appium-Python3--UI自动化-[-15-]-报错:configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%)'] 的解决

    报错内容:

    Failed to import test module: app.BusinessProcess.testLendRequestProcess.testPrivateOwner.test_001_lend_request_private_owner_module
    Traceback (most recent call last):
    File "C:Python36libunittestloader.py", line 428, in _find_test_path
    module = self._get_module_from_name(name)
    File "C:Python36libunittestloader.py", line 369, in _get_module_from_name
    __import__(name)
    File "C:chushujinstudysales_ui_auto estCaseappBusinessProcess estLendRequestProcess estPrivateOwner est_001_lend_request_private_owner_module.py", line 9, in <module>
    from page.app.BusinessProcess.testLendRequestProcess.testPrivateOwner.page_sales_lend_request_private_owner_module import PageSalesLendRequestPrivateOwner
    File "C:chushujinstudysales_ui_autopageappBusinessProcess estLendRequestProcess estPrivateOwnerpage_sales_lend_request_private_owner_module.py", line 8, in <module>
    from locator.app.BusinessProcess.testLendRequestProcess.testPrivateOwner.locator_sales_lend_request_private_owner_module import LocatorSalesLendRequestPrivateOwner
    File "C:chushujinstudysales_ui_autolocatorappBusinessProcess estLendRequestProcess estPrivateOwnerlocator_sales_lend_request_private_owner_module.py", line 9, in <module>
    class LocatorSalesLendRequestPrivateOwner:
    File "C:chushujinstudysales_ui_autolocatorappBusinessProcess estLendRequestProcess estPrivateOwnerlocator_sales_lend_request_private_owner_module.py", line 18, in LocatorSalesLendRequestPrivateOwner
    lend_request_private_owner_proportion_of_shares_xpath = myConfig.getAppElement("lend_request_private_owner_proportion_of_shares_xpath")
    File "C:chushujinstudysales_ui_autocommmy_config.py", line 62, in getAppElement
    app_Element = config.get('appElement',key)
    File "C:Python36libconfigparser.py", line 800, in get
    d)
    File "C:Python36libconfigparser.py", line 394, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
    File "C:Python36libconfigparser.py", line 444, in _interpolate_some
    "found: %r" % (rest,))
    configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%)']/following::android.widget.EditText"

    总的分析来说 ,最后一句才是重点:读取配置文件config.ini时候,里面存在%引起的

    解决方法一:

    configparser很可能正在读取字符串中的文字“%”符号。'%'符号用于字符串插值(替代)。如果要使用文字“%”,可以使用另一个“%”对其进行转义。例如,在configparser读取的配置变量中,使用“ 100 %%”表示“ 100%”。

    解决方法二:

    cf= configparser.ConfigParser()

    改为:

    cf = configparser.RawConfigParser()

  • 相关阅读:
    第三次博客园作业
    centos7+jdk1.8+tomcat8 配置https
    输入30个数存入数组a,求出数的每个位数的平方和存入数组b,从小到大排列后输出(C语言)
    50个[100,300]的随机数,要求用二分法查找从键盘录入的关键数字。找到回复位置,找不到回复不存在(C语言)
    产生20个随机数,在[200,400]内,其中能被5整除的存入数组array2,要求输出array2中的平均值(C语言)
    最小生成树
    PTA路径判断
    PTA构造哈夫曼树
    图的其中两种表示方式
    中序遍历树并判断是否为二叉搜索树
  • 原文地址:https://www.cnblogs.com/chushujin/p/13692939.html
Copyright © 2011-2022 走看看