-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_selenium.py
More file actions
123 lines (101 loc) · 3.48 KB
/
test_selenium.py
File metadata and controls
123 lines (101 loc) · 3.48 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from selenium import webdriver
from selenium.webdriver.edge.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
#Opening the browser
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Edge(options=options) # attach only
driver.maximize_window()
time.sleep(2)
#Locating Loggings
"""
user_name = WebDriverWait(driver, 15).until(
EC.visibility_of_element_located((By.ID, "exampleInputEmail1"))
)
user_name.clear()
user_name.send_keys("betty")
time.sleep(2)
driver.find_element(By.XPATH, "//button[text()='Next']").click()
time.sleep(2)
password_input = WebDriverWait(driver, 15).until(
EC.visibility_of_element_located((By.ID, "exampleInputPassword1"))
)
password_input.clear()
password_input.send_keys("2027")
time.sleep(2)
driver.find_element(By.XPATH, "//button[text()='Login']").click()
time.sleep(5)
print("Login clicked once")
"""
module_button = WebDriverWait(driver, 15).until(
EC.element_to_be_clickable((By.CLASS_NAME, "sizeforsmalldevice"))
)
module_button.click()
daily_reports = WebDriverWait(driver, 15).until(
EC.element_to_be_clickable((By.XPATH, "//a[contains(text(),'Daily Reports')]"))
)
daily_reports.click()
time.sleep(3)
#Left pane
other_modules_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.LINK_TEXT, "Other Module Reports"))
)
other_modules_button.click()
stock_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.LINK_TEXT, "Stock Related Reports"))
)
stock_button.click()
profitability_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.LINK_TEXT, "Profitability"))
)
profitability_button.click()
#Navigating to the profitability report
driver.find_element(By.LINK_TEXT, "Organisation Hierarchy").click()
time.sleep(2) # small pause for dropdown to appear
# Selecting the organisation
org_input = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='Branch']"))
)
org_input.clear()
org_input.send_keys("Enjoy Emma Brenda Membley")
time.sleep(1)
org_input.send_keys(Keys.DOWN)
org_input.send_keys(Keys.ENTER)
driver.find_element(By.XPATH, "//button[text()='Add Filter']").click() # Add filter
time.sleep(3)
#Selecting Department
driver.find_element(By.LINK_TEXT, "classification").click()
time.sleep(1)
#Classification operation
operation_dropdown = driver.find_elements(By.TAG_NAME, "select")[0]
operation_dropdown.click()
time.sleep(0.5)
operation_dropdown.send_keys("Between")
operation_dropdown.send_keys(Keys.DOWN)
operation_dropdown.send_keys(Keys.ENTER)
time.sleep(1)
#product classification
level_dropdown = driver.find_elements(By.TAG_NAME, "select")[1]
level_dropdown.click()
time.sleep(0.5)
level_dropdown.send_keys("DEPARTMENT")
level_dropdown.send_keys(Keys.DOWN)
level_dropdown.send_keys(Keys.ENTER)
time.sleep(1)
#From to Department
from_input = driver.find_element(By.XPATH, "//input[@placeholder='From Value']")
from_input.send_keys("Water")
from_input.send_keys(Keys.DOWN)
from_input.send_keys(Keys.ENTER)
time.sleep(1)
to_input = driver.find_element(By.XPATH, "//input[@placeholder='To Value']")
to_input.send_keys("Water")
to_input.send_keys(Keys.DOWN)
to_input.send_keys(Keys.ENTER)
time.sleep(1)
driver.find_element(By.XPATH, "//button[text()='Add Filter']").click() #Add filter
time.sleep(2)