forked from Andy-ITFactory/WorkshopAutomation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_test.py
58 lines (41 loc) · 1.8 KB
/
start_test.py
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
# avem nevoie sa importam cateva librarii gratuite care ne ajuta sa controlam chrome
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# initializam chrome
chrome = webdriver.Chrome()
# navigam catre un url
chrome.get("https://formy-project.herokuapp.com/form")
# cu sleep putem pune pauza de cateva secunde sa asteptam sa vedem si noi ceva
sleep(3)
'''
exercitiu - maximizam fereastra
toate comenzile incep cu chrome. si sunt intuitive
scrie mai jos chrome. si gandeste-te care ar putea fi comanda corecta
'''
# gasim first name dupa ID si scriem valori in formular
chrome.find_element(By.ID, "first-name").send_keys("Andy")
sleep(3)
# exercitiu: completam impreuna nume apoi punem un sleep de 3 secunde
# exercitiu: completeaza singur job title (nu uitam de sleep)
# exercitiu: select education - nu mai folosim .send_keys() la final. ce metoda crezi ca ar merge aici?
# exercitiu: select gender (nu uitam de sleep)
'''
exercitiu: dam click pe submit apoi punem un sleep de 3 secunde
vom invata ce sa facem cand elementul nu are ID
metoda 1: copiem XPATH unic al elementului
metoda 2: intrebam AI https://chat.openai.com/chat
ne va raspunde cu "//a[@class='btn btn-lg btn-primary' and @role='button' and @href='/thanks']"
vezi aici: https://www.itfactory.ro/wp-content/uploads/2023/04/ChatGPT.jpg
'''
# inchidem chrome
chrome.quit()
# daca a trecut testul, printam in consola un mesaj de succes
print("SUCCESS - TEST PASSED")
'''
exercitiu final:
stergem toate comenzile de sleep pentru a vedea viteza testului in timp real
aceasta EFICIENTA ofera o valoare ENORMA si PERMANENTA angajatorilor
costul acestui test tinde spre 0, o data ce a fost scris
asa ca ei vor plati FOARTE BINE o data, ca sa primeasca si sa ramana cu aceasta valoare care ulterior, tinde spre ∞
'''