When writing the PO, I tried to separate the page and case files into different folders, but I had a problem calling the module. It was finally settled. Record it

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – line — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — ——————

1. The pages folder stores page files and the test_cases folder stores test cases

2. The file structure is as follows:

–pages

—–login_pg.py

–test_cases

—–1_test_login.py

Now 1 _test_login. Call login_pg in py. Py, this kind of circumstance is across directories call module, it must be under the folder pages, first create a set p y, this page is a complete module, can be called.

Login_pg. py (test_cases, login_pg.py);

import sys,os

Parentdir = os.path.dirname(os.path.abspath(__file__)) # Call sys.path.insert(0, parentdir)

From pages. Login_pg import LoginPage #

######## However, after this import, the problem here is resolved and there are other problems ###############

Question: under the pages login_pg. Py, and invoke the pages under base_pg. Py in the class, the original writing: the from base_pg import BasePage, but an error now, can’t find base_pg this module.

From. Base_pg import BasePage(PS: add dots to form a reference to login_pg) and you should be done

But if you add, you can make other mistakes later, so I’ll write it like this: When it’s too normal to go in, you add

try:

from base_pg import BasePage

except ImportError:

from .base_pg import BasePage

— — — — — — — — — — — — — — — — — — — — – the above still need to figure out the python mechanism of led package can — — — — — — — — — — — — — — — — — —

Do some research for yourself