我希望自动化网站的登录功能,只需将用户名和密码的不同值作为参数传递,并为每对值测试登录功能。
示例:
def login(username,password):
driver.find_element(BYelemantLocator1).send_keys(username)
driver.find_element(BYelemantLocator1).send_keys(password)
driver.find_element(BYelemantLocatorSubmitButton).click()
def test_login():
login(admin,admin)
答案 0 :(得分:0)
类LoginDetails(object): def init (自我):
self.driver = webdriver.Firefox()
self.homePageURL = "http://hulk.iwanto.in/"
def logindetails(self, username, password):
driver = self.driver
wait = WebDriverWait(driver, 10)
driver.maximize_window()
driver.get(self.homePageURL)
driver.implicitly_wait(30)
driver.find_element(*LoginPage.signIn_Button).click()
driver.find_element(*LoginPage.emailHeader).send_keys(username)
driver.find_element(*LoginPage.signIn).click()
driver.find_element(*LoginPage.passwordHeader).send_keys(password)
driver.find_element(*LoginPage.loginButton).click()
wait.until(EC.element_to_be_clickable((By.ID, 'submit_approve_access')))
driver.find_element(*LoginPage.allowAccess).click()
# Login Success
class TestLogin(unittest.TestCase):
def setUp(self):
self.ld = LoginDetails()
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
def test_sr_Login(self):
self.ld.logindetails(LoginPage.emailValue, LoginPage.passwordValue)