我在Python的Pycharm
中使用Selenium WebDriver
,其中我使用的类有2个测试函数。在
class goodsweb(unittest.TestCase):
def setUp(self):
driverlocation ="/Users/new/Documents/Learning/Drivers/selenium-2.53.1/py/selenium/webdriver/chromedriver"
os.environ["webdriver.chrome.driver"] = driverlocation
self.driver = webdriver.Chrome(driverlocation)
def test_Test1(self):
self.EmailEntry = input("Please Enter Email Address: ")
self.EmailAddress.send_keys(self.EmailEntry)
self.Password.clear()
self.password='12345678'
self.Password.send_keys(self.password)
def test_Test2(self):
self.LoginEmail = driver.find_element_by_xpath("//*[@id='sign_form-default']//div[1]/input[@type='email']")
self.LoginEmail.clear()
self.LoginEmail.click()
self.LoginEmail.send_keys(self.EmailEntry)
self.LoginPassword = driver.find_element_by_xpath("//*[@id='sign_form-default']//div[1]/input[@type='password']")
self.LoginPassword.clear()
self.LoginPassword.click()
self.LoginPassword.send_keys(self.password)
现在我想要的是在test_Test2
中获得EmailEntry
和{test_Test1
的访问权
每当我运行代码时,都会出现以下错误:
AttributeError: 'goodsweb' object has no attribute 'EmailEntry'
在goodsweb类中无法访问。在该类中声明或定义为静态,以便可以在任何其他类中使用。在
如果要在其他类或函数中使用一个字段,则必须将该字段定义为静态字段。在
函数的概念是相同的。您可以将函数定义为静态类
对于python::
^{pr2}$相关问题 更多 >
编程相关推荐