报错内容:
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()