My code is..
from selenium import webdriver
from selenium.webdriver.common.by import By
import unittest
import time
import json
class ADDSTEST(unittest.TestCase):
@classmethod
def setUpClass(cls):
global driver
driver = webdriver.Firefox("D:/Frontend/18-01-2021/selenium-testing")
driver.get("http://localhost:4200")
driver.maximize_window()
def test_login(self):
with open('D:/Frontend/18-01-2021/selenium-testing/testing/inputcredentials.json') as jsonString:
jsonObject = json.load(jsonString)
for val in jsonObject:
usersname = val["username"]
Password = val["password"]
driver.find_element(By.NAME,'username').send_keys(usersname)
driver.find_element(By.NAME,'password').send_keys(Password)
driver.find_element_by_id('login').click()
time.sleep(6)
driver.find_element_by_id('log_out').click()
@classmethod
def tearDownClass(cls):
driver.close()
unittest.main()
And I have to check the above code for different usernames and passwords in json array and the json I have created is..
**user.json**
[{"username":"admin","password":"admin@123"},{"username":"admin123","password":"admin@12345"},{"username":"abcdef","password":"abcs@123"},{"username":"user", "password":"admin@123"},{"username":"bbbs","password":"admin@123"}]
I have to check the above json array of usernaem and password and if it is correct go to dashboard page and logout, and if it is wrong it has refresh the page again.
So my requirement is how to check if the user is navigated to dashboard page or not
Aucun commentaire:
Enregistrer un commentaire