我是编写自动化测试的新手,我觉得我肯定遗漏了一些非常明显的东西
这是我的代码。
Class BIIAccountPreferencesTest(CoreTest):
def testAccountPreferences(self):
lp = BIILoginPage(self.driver)
hp = lp.biiLoginUser(config.biisubscriber_username , config.biisubscriber_password)
d = self.driver
print "\n Changing user and company name"
d.get(config.bii_url + '/account')
d.find_element_by_css_selector('#user-fullname').clear()
d.find_element_by_css_selector('#user-company').clear()
d.find_element_by_css_selector('#user-fullname').send_keys(random.choice(string.ascii_uppercase) for x in range(7))
d.find_element_by_css_selector('#user-company').send_keys(random.choice(string.ascii_uppercase) for x in range (5))
d.find_element_by_css_selector('#user-Save').click()
a = d.find_element_by_css_selector('body > div.container.clearfix > p').text
b = "Your account information has been updated"
self.assertTrue(str(b) in str(a))
当我运行此代码时,它不断向我抛出此错误“NameError:未定义名称'd'”我没有在正确的时刻声明 d = self.driver 吗?我使用 self.driver 因为我通过 saucelabs 运行它