-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunSeleniumTest.py
More file actions
76 lines (63 loc) · 2.37 KB
/
RunSeleniumTest.py
File metadata and controls
76 lines (63 loc) · 2.37 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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from pprint import pprint
from time import sleep
def alerting(message):
driver.execute_script("alert('" + message + "')")
sleep(3)
alert = driver.switch_to_alert()
alert.dismiss()
target_miq_from_sprout = 'https://10.8.59.164/'
driver = webdriver.Firefox()
driver.get(target_miq_from_sprout)
alerting("After setting URL, starting from logging in...")
userName = driver.find_element_by_id("user_name")
userName.send_keys("admin")
userPass = driver.find_element_by_id("user_password")
userPass.send_keys("smartvm")
loginButton= driver.find_element_by_id("login")
loginButton.click()
print ("Checkpoint 1")
sleep(10)
alerting('Just logged in, start to navigate by clicking...')
#menu1 = driver.find_elements_by_xpath("//ul[@id='maintab']/li[@class='dropdown']/a[contains(@class,'visible-lg')]")
menu1 = driver.find_elements_by_xpath("//ul[@id='maintab']/li[@class='dropdown']/a[contains(@class,'visible-lg')]")
menu2 = driver.find_elements_by_xpath("//ul[@id='maintab']/li[@class='active']/a[contains(@class,'visible-lg')]")
#print("Size of found: {count}".format(count = len(menu1)+len(menu2)))
items = []
for item in menu1:
it = item.get_attribute("innerText")
items.append(it)
for item in menu2:
it = item.get_attribute("innerText")
items.append(it)
for it in items:
elem = driver.find_element_by_partial_link_text(it)
# print(it)
elem.click()
sleep(5)
alerting('And then by mouse hovering, vertically...')
#print("Stop clicking. Hovering...")
# hover0 = ActionChains(driver)
for it in items:
dropmenu = driver.find_element_by_partial_link_text(it)
item_class = dropmenu.get_attribute("class")
# print(it + "(" + item_class + ")")
hover = ActionChains(driver)
hover.move_to_element(dropmenu)
hover.perform()
drops = dropmenu.find_elements_by_xpath("../ul/li/a")
if it=="Infrastructure":
alerting('Mouse hovering horizontally!')
for drop in drops:
# print(" > " + drop.get_attribute("innerText"))
innerHover = ActionChains(driver)
innerHover.move_to_element(drop)
innerHover.perform()
sleep(1)
sleep(1)
print ("Checkpoint 2")
alerting('That\"s all! Something like this...')
sleep(5)
driver.quit()