Exemplo n.º 1
0
 def show_passworderror(self):
     try:
         passworderror = self.find_element(*self.loc_passworderror)
         highlight(passworderror)
         return passworderror.text
     except:
         return self.element_status
Exemplo n.º 2
0
 def show_nameerror(self):
     try:
         nameerror = self.find_element(*self.loc_nameerror)
         highlight(nameerror)
         return nameerror.text
     except:
         return self.element_status
Exemplo n.º 3
0
 def click_submit(self):
     login_button = self.find_element(*self.loc_loginbutton)
     highlight(login_button)
     login_button.click()
Exemplo n.º 4
0
 def input_password(self, password):
     pwd = self.find_element(*self.loc_password)
     highlight(pwd)
     pwd.clear()
     pwd.send_keys(password)
Exemplo n.º 5
0
 def input_username(self, username):
     name = self.find_element(*self.loc_name)
     highlight(name)
     name.clear()
     name.send_keys(username)
Exemplo n.º 6
0
#base_path=os.path.dirname(os.path.abspath(__file__))+'\..'
#driver_path=os.path.abspath(base_path+'\drivers\chromedriver.exe')

loc_name = (By.ID, "username")
loc_password = (By.ID, "password")
loc_loginbutton = (By.XPATH, ".//*[@id='loginInfo']/button")

browser = webdriver.Firefox()
browser.implicitly_wait(10)
browser.get(LoginURL)
browser.maximize_window()
#time.sleep(1)

#输入用户名
username = browser.find_element(*loc_name)
highlight(username)
username.clear()
username.send_keys(datas[0][0])

#输入密码
password = browser.find_element(*loc_password)
highlight(password)
password.clear()
password.send_keys(datas[0][1])

#点击登录按钮
loginbutton = browser.find_element(*loc_loginbutton)
highlight(loginbutton)
loginbutton.click()

time.sleep(1)