forked from EGCETSII/decide_django_2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EGCETSII#43-fix: rename selenium tests and avoid workflow call
- Loading branch information
Showing
1 changed file
with
64 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,137 +20,161 @@ | |
''' | ||
|
||
|
||
#USER TESTS | ||
def log_in(driver, cont): | ||
# USER TESTS | ||
def log_in(driver, cont): | ||
try: | ||
print("Test LogIn") | ||
time.sleep(2) | ||
driver.get('http://localhost:8000/administration/') | ||
time.sleep(2) | ||
driver.find_element(By.XPATH,'//*[@id="content"]/div/form/div[1]/div/input').send_keys("admin") | ||
driver.find_element(By.XPATH,'//*[@id="content"]/div/form/div[2]/div/input').send_keys("qwerty") | ||
driver.find_element(By.XPATH,'//*[@id="content"]/div/form/button').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/div[1]/div/input').send_keys("admin") | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/div[2]/div/input').send_keys("qwerty") | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/button').click() | ||
time.sleep(2) | ||
print("Test correctamente realizado\n") | ||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
def log_out(driver, cont): | ||
try: | ||
print("Test LogOut") | ||
driver.get('http://localhost:8000/administration/') | ||
time.sleep(2) | ||
driver.find_element(By.XPATH, '//*[@id="root"]/div/div[1]/button').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="root"]/div/div[1]/button').click() | ||
time.sleep(1) | ||
print("Test correctamente realizado\n") | ||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
def incorrect_log_in(driver, cont): | ||
try: | ||
print("Test LogIn Incorrecto") | ||
driver.get('http://localhost:8000/administration/') | ||
driver.find_element(By.XPATH, '//*[@id="content"]/div/form/div[1]/div/input').send_keys("badadmin") | ||
driver.find_element(By.XPATH, '//*[@id="content"]/div/form/div[2]/div/input').send_keys("qwerty") | ||
driver.find_element(By.XPATH, '//*[@id="content"]/div/form/button').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/div[1]/div/input').send_keys("badadmin") | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/div[2]/div/input').send_keys("qwerty") | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/button').click() | ||
time.sleep(1) | ||
elemento = driver.find_element(By.XPATH,'//*[@id="content"]/div/form/div[2]/p') | ||
elemento = driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/form/div[2]/p') | ||
error_text = 'Unable to log in with provided credentials.' | ||
if elemento.text == error_text: | ||
print("Test correctamente realizado\n") | ||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
def create_user(driver, cont): | ||
try: | ||
print("Test Create User") | ||
time.sleep(1) | ||
driver.get("http://localhost:8000/administration/users") | ||
time.sleep(4) | ||
driver.find_element(By.XPATH, '//*[@id="actions"]/div/button[1]').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="actions"]/div/button[1]').click() | ||
time.sleep(4) | ||
numalea = str(random.randint(0,9)) + str(random.randint(0,9))+ str(random.randint(0,9)) | ||
username = str("nuevouser"+ str(numalea)) | ||
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[1]/div/input').send_keys(username) | ||
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[2]/div/input').send_keys("passwordNew") | ||
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[3]/div/input').send_keys("Nueva") | ||
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[4]/div/input').send_keys("Cuenta") | ||
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[5]/div/input').send_keys("[email protected]") | ||
numalea = str(random.randint(0, 9)) + \ | ||
str(random.randint(0, 9)) + str(random.randint(0, 9)) | ||
username = str("nuevouser" + str(numalea)) | ||
driver.find_element( | ||
By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[1]/div/input').send_keys(username) | ||
driver.find_element( | ||
By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[2]/div/input').send_keys("passwordNew") | ||
driver.find_element( | ||
By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[3]/div/input').send_keys("Nueva") | ||
driver.find_element( | ||
By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[4]/div/input').send_keys("Cuenta") | ||
driver.find_element( | ||
By.XPATH, '/html/body/div[2]/div[3]/div/form/div[1]/div/div/div[5]/div/input').send_keys("[email protected]") | ||
time.sleep(2) | ||
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div/form/div[2]/button').click() | ||
driver.find_element( | ||
By.XPATH, '/html/body/div[2]/div[3]/div/form/div[2]/button').click() | ||
time.sleep(5) | ||
print("Test correctamente realizado\n") | ||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
def make_staff(driver, cont): | ||
try: | ||
driver.get("http://localhost:8000/administration/users") | ||
print("Test hacer staff") | ||
driver.find_element(By.XPATH,'//*[@id="content"]/div/div/div[2]/div[2]/div/div/div/div[4]/div[1]/span/input').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/div/div[2]/div[2]/div/div/div/div[4]/div[1]/span/input').click() | ||
time.sleep(2) | ||
driver.find_element(By.XPATH, '//*[@id="actions"]/div/button[5]').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="actions"]/div/button[5]').click() | ||
#driver.find_element(By.XPATH, '') | ||
print("Test correctamente realizado\n") | ||
|
||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
def make_superuser(driver, cont): | ||
try: | ||
driver.get("http://localhost:8000/administration/users") | ||
print("Test hacer superuser") | ||
driver.find_element(By.XPATH,'//*[@id="content"]/div/div/div[2]/div[2]/div/div/div/div[4]/div[1]/span/input').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/div/div[2]/div[2]/div/div/div/div[4]/div[1]/span/input').click() | ||
time.sleep(2) | ||
driver.find_element(By.XPATH, '//*[@id="actions"]/div/button[6]').click() | ||
#print(element) | ||
driver.find_element( | ||
By.XPATH, '//*[@id="actions"]/div/button[6]').click() | ||
# print(element) | ||
#driver.find_element(By.XPATH, '') | ||
print("Test correctamente realizado\n") | ||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
def delete_user(driver, cont): | ||
try: | ||
driver.get("http://localhost:8000/administration/users") | ||
print("Test borrar usuario") | ||
driver.find_element(By.XPATH,'//*[@id="content"]/div/div/div[2]/div[2]/div/div/div/div[4]/div[1]/span/input').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="content"]/div/div/div[2]/div[2]/div/div/div/div[4]/div[1]/span/input').click() | ||
time.sleep(2) | ||
driver.find_element(By.XPATH, '//*[@id="actions"]/div/button[3]').click() | ||
driver.find_element( | ||
By.XPATH, '//*[@id="actions"]/div/button[3]').click() | ||
time.sleep(1) | ||
print("Test correctamente realizado\n") | ||
return cont | ||
except Exception as e: | ||
print("Error") | ||
print(e) | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
|
@@ -159,18 +183,18 @@ def base(driver, cont): | |
print("Test") | ||
driver.find_element(By.XPATH, '') | ||
return cont | ||
except : | ||
except: | ||
print("Error") | ||
cont = cont +1 | ||
cont = cont + 1 | ||
return cont | ||
|
||
|
||
if __name__ == "__main__": | ||
cont = 0 | ||
options = webdriver.ChromeOptions() | ||
driver = webdriver.Chrome(options=options) | ||
#USER TESTS | ||
|
||
# USER TESTS | ||
cont = incorrect_log_in(driver, cont) | ||
cont = log_in(driver, cont) | ||
cont = create_user(driver, cont) | ||
|
@@ -186,6 +210,4 @@ def base(driver, cont): | |
cont = log_out(driver, cont) | ||
|
||
print("Se han realizado Test de FrontEnd") | ||
print("Se han encontrado: "+ str(cont) + " errores ") | ||
|
||
|
||
print("Se han encontrado: " + str(cont) + " errores ") |