-1

I want to automate the login functionality of a site in such a way that i just pass the different values of username and password as parameters and the login functionality is tested for each pair of values.

example:

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)
user861594
  • 5,733
  • 3
  • 29
  • 45
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. – malarzm Jun 21 '16 at 19:51
  • I want to automate Login functionality using selenium web driver with python. Step 1: Create a function which finds all the elements and inputs all the necessary details (such as username and password) and logs in the user. Step 2: Pass different values of username and password as parameters and test login functionality for various username-password combinations. Thanks for the help @malarzm – Akshay Malhotra Jun 21 '16 at 19:54
  • By searching this site and googling others, you should be able to find all you need to accomplish this. So, what specifically are you asking here? I don't see an actual question. Your question should be around a specific issue not a code for hire request (which is what this looks like). – JeffC Jun 21 '16 at 20:42
  • Hi @malarzm, My code started to work. Resolved the error. Thanks – Akshay Malhotra Jun 21 '16 at 20:59
  • If you find solution please share it with others. – kotoj Jun 22 '16 at 07:33

1 Answers1

0

class LoginDetails(object): def init(self):

    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)

Passing Parameters

def test_sr_Login(self):
    self.ld.logindetails(LoginPage.emailValue, LoginPage.passwordValue)