문제

im new to writing automated tests and I feel like I am definitely missing something very obvious

Here is my code.

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))

When I run this code it keeps throwing me this error "NameError: name 'd' is not defined" Am I not declaring d = self.driver at the right moment? I use self.driver since im running this through saucelabs

도움이 되었습니까?

해결책

Your code is mixing tab and spaces and it's not considered indented as you think it is.

Just set up your editor to avoid tab characters completely (decent editors can do this and still use the tab key for indentation).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top