This still does not work for some strange reason. Here is my tree structure:
TestProject/ ├── __init__.py ├── Locators │ ├── __init__.py │ └── locators.py <---- Locators location ├── POM │ ├── homePage.py │ ├── homePage_wl.py <----- importing from Locators │ ├── __init__.py │ ├── loginPage.py │ ├── loginPage_wl.py <----- importing from Locators │ └── __pycache__ │ ├── homePage.cpython-37.pyc │ ├── __init__.cpython-37.pyc │ ├── loginPage.cpython-37.pyc │ └── loginPage_wl.cpython-37.pyc ├── __pycache__ │ ├── login.cpython-37.pyc │ ├── login_pom.cpython-37.pyc │ ├── test_login.cpython-37.pyc │ ├── test_login_pom.cpython-37.pyc │ └── test_login_pom_wl.cpython-37.pyc ├── test_login_pom.py ├── test_login_pom_wl.py ├── test_login.py └── tree.txt
From the file /POM/loginPage_wl.py I import like this:
from TestProject.Locators.locators import Locators
And I see the same error:
ImportError: Failed to import test module: test_login_pom_wl Traceback (most recent call last): File "/media/Work/anaconda3/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName module = __import__(module_name) File "/media/Work/Work/selenium/TestProject/test_login_pom_wl.py", line 5, in <module> from POM.loginPage_wl import LoginPage File "/media/Work/Work/selenium/TestProject/POM/loginPage_wl.py", line 1, in <module> from TestProject.Locators.locators import Locators ModuleNotFoundError: No module named 'TestProject'
I looked all over the network and not a single soul worked. Any suggestions?
source share