• 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()

  • 相关阅读:
    设计模式开篇——7大设计原则
    MySQL MVCC专题
    Spring常考的面试题
    HashMap常考面试题
    Equals和==的比较
    高并发编程
    一文读懂JVM
    scala实现定时任务的方法
    PLAY2.6-SCALA(十二) 表单的处理
    PLAY2.6-SCALA(十一) 模板常用场景
  • 原文地址:https://www.cnblogs.com/chushujin/p/13692939.html
Copyright © 2020-2023  润新知