我正在努力解决如何使用两个文件之间的相同参数。这是我遇到的问题......
我有locators.py。请注意,此处的fileName是在diff文件中声明的参数
class Locatars(object):
# Configuration locater
# note that the fileName here is the parameter declared in a diff file
FILENAME = (By.XPATH, //a[contains(@href, '" + fileName + "')])
here is another file called mainPage.py
class mainPage(Page):
def __init__(self, driver):
super(mainPage, self).__init__(driver)
def buttonClick(self, fileName):
self.driver.find_element(Locatars.FILENAME).click()
但是,当我运行mainPage.py时,它会出现错误并且无法识别locators.py文件中的fileName
答案 0 :(得分:0)
您需要导入定位器文件:
import locators
或
from locators import Locators
请注意,我假设您的两个文件位于同一目录中(或在Python路径上)。