0

I want to Automate Web App testing using Selenium and PyTest and I am new to both. So here is the structure of my project folder:

Parent Folder Locator.py

Section 1(Folder) -> test_sectionone.py

Locator.py contains all my Xpaths. Now when I try to import Locator.py by typing import Locator and then fetching the xpath using Locator.xpathElement1 in the test_sectionone.py, pytest fails with the following error:

Hint: make sure your test modules/packages have valid Python names. Traceback: test_mailboxProvisioning.py:5: in import Locator E ModuleNotFoundError: No module named 'Locator'

Is there something I am missing? Is there a naming convention because of which I am facing the issue?

0

1 Answer 1

0

Convert Parentfolder into a python package by including an empty file __init__.py Convert sub folder "Section1" into a python package by including an empty file __init__.py

In test_sectionone.py now either import ParentFolder.Locator (using absolute path) or from ..Locator import function using relative path. Both should work.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.