-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadTest.py
More file actions
63 lines (45 loc) · 2.05 KB
/
loadTest.py
File metadata and controls
63 lines (45 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from selenium import webdriver
from selenium.webdriver.common.by import By
from concurrent.futures import ThreadPoolExecutor
from selenium.webdriver.common.keys import Keys
import time
# Función que realiza las acciones de prueba en una instancia de WebDriver
def realizar_acciones_de_prueba():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-gpu")
driver = webdriver.Chrome(options=chrome_options)
driver.implicitly_wait(10)
driver.get('https://www.saucedemo.com')
usuario = driver.find_element(By.ID, "user-name")
usuario.send_keys("standard_user")
contra = driver.find_element(By.ID, "password")
contra.send_keys("secret_sauce")
usuario.send_keys(Keys.ENTER)
ButtonSauceBack = driver.find_element(By.ID, "add-to-cart-sauce-labs-backpack")
ButtonSauceBack.click()
ButtonSauceBike = driver.find_element(By.ID, "add-to-cart-sauce-labs-bike-light")
ButtonSauceBike.click()
Carrito = driver.find_element(By.CLASS_NAME, "shopping_cart_link")
Carrito.click()
CheckOut = driver.find_element(By.ID, "checkout")
CheckOut.click()
FirstName = driver.find_element(By.ID, "first-name")
FirstName.send_keys("Diego")
LastName = driver.find_element(By.ID, "last-name")
LastName.send_keys("Cruz")
Zip = driver.find_element(By.ID, "postal-code")
Zip.send_keys("1234")
BContinue = driver.find_element(By.ID, "continue")
BContinue.click()
BFinish = driver.find_element(By.ID, "finish")
BFinish.click()
AlertFinish = driver.find_element(By.CLASS_NAME, "complete-header")
assert AlertFinish.text == "THANK YOU FOR YOUR ORDER", "El valor obtenido no es igual al esperado"
driver.quit()
# Número de usuarios virtuales concurrentes
numero_de_usuarios = 2
# Crea un ThreadPoolExecutor para ejecutar múltiples instancias de WebDriver
with ThreadPoolExecutor(max_workers=numero_de_usuarios) as executor:
for _ in range(numero_de_usuarios):
executor.submit(realizar_acciones_de_prueba)