我在package(页面,基础)和测试目录中创建了一些自定义模块,而我从页面和基础中导入模块的测试模块也很少。
页面包中的模块:
pom_login_page.py -->it has PM_Login_Page class
pom_pm_homepage.py --> it has PM_HomePage class
pom_pm_userpage.py --_ it has PM_UserPage class
modules in base package:
selenium_driver.py --> it has Selenium_Driver class
webdriver_factory.py --> it has WebdriverFactory class
Below are import statements in test_pm_login_tests.py file present in tests package.
: 导入单元测试 导入pytest 从Utility.delete_user_data导入Delete_User_Data 导入日志 从pages.pom_pm_user_page导入PM_Users_Page 从pages.pom_login_page导入PmLoginPage
当我尝试执行test_pm_login_tests.py时,出现以下错误:
_______________________________________________ ERROR collecting test_pm_login_tests.py ________________________________________________
ImportError while importing test module 'C:\Users\mallikar\Documents\Python_Workspace\PM_SNM_Automation\tests\test_pm_login_tests.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_pm_login_tests.py:1: in <module>
from pages.pom_login_page import PmLoginPage
..\pages\pom_login_page.py:1: in <module>
from base.selenium_driver import SeleniumDriver
..\base\selenium_driver.py:7: in <module>
from utilities.util import Util
..\utilities\util.py:5: in <module>
from snm_pages.pom_snm_loginpage import SNM_Login_Page
..\snm_pages\pom_snm_loginpage.py:1: in <module>
from base.selenium_driver import SeleniumDriver
E ImportError: cannot import name 'SeleniumDriver' from 'base.selenium_driver' (C:\Users\mallikar\Documents\Python_Workspace\PM_SNM_Aut
omation\base\selenium_driver.py)
几天来运行良好,但今天我面临这些问题。
任何对此的帮助都会对我有很大帮助。