Skip to content

Commit 3800728

Browse files
yichi.lusebgoa
authored andcommitted
initial check in
Signed-off-by: Sebastien Goasguen <[email protected]>
1 parent 90262a8 commit 3800728

11 files changed

Lines changed: 580 additions & 0 deletions

File tree

test/selenium/browser/__init__.py

Whitespace-only changes.

test/selenium/browser/firefox.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from selenium import webdriver
2+
import time
3+
from selenium.common.exceptions import WebDriverException
4+
from selenium.common.exceptions import NoSuchElementException
5+
6+
class Firefox(object):
7+
def __init__(self, x_pos = 0, y_pos = 0, x_size = 1024, y_size = 768, timeout = 30):
8+
self.browser = None
9+
self.browser = webdriver.Firefox()
10+
self.browser.set_page_load_timeout(timeout)
11+
self.browser.set_window_position(x_pos, y_pos)
12+
self.browser.set_window_size(x_size, y_size)
13+
14+
def get_browser(self):
15+
return self.browser
16+
17+
def set_url(self, url):
18+
if url == None or url == "":
19+
print "A valid url is required"
20+
return
21+
self.url = url
22+
self.browser.get(url)
23+
24+
def quit_browser(self):
25+
try:
26+
self.browser.quit()
27+
except NoSuchElementException as err:
28+
print "Element error({0})".format(err.msg)
29+
except WebDriverException as err:
30+
print "WebDriver error({0})".format(err.msg)
31+
32+
33+
if __name__ == "__main__":
34+
# Create a new instance of the Firefox driver
35+
browser = Firefox("Firefox")
36+
browser.set_url("http://10.88.90.84:8080/client/")
37+
time.sleep(3)
38+
browser.quit_browser()
39+
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
'''
19+
Variable Names are as follows
20+
Logical Page Descriptor_____What Element Represents and/or where it is_____LocatorType
21+
22+
23+
For Example ::
24+
25+
instances_xpath = "//div[@id='navigation']/ul/li[2]/span[2]"
26+
27+
Means this is:: xpath link for Instances which is present on Dashboard.
28+
Any test cases that requires to go into Instances from Dashboard can use this variable now.
29+
30+
This may not be intuitive as you go deep into the tree.
31+
32+
33+
34+
for example
35+
36+
stopinstanceforce_id
37+
38+
The best way to know what this represents is to track by variable name
39+
Under Instances / any instance is click on any instance (applies to any instance) / stop instance has a force stop check box when you click.
40+
This link represents that.
41+
42+
43+
Steps below do not have global locators.
44+
45+
PF rule steps including and after filling port numbers. (Refer to vmLifeAndNetwork.py / def test_PF)
46+
FW rule steps including and after filling port numbers. (Refer to vmLifeAndNetwork.py / def test_PF)
47+
ADD Disk Offering page has Names, description, storage type etc etc
48+
ADD Compute Offering page has Names, description, CPU Cores, CPU clocks type etc etc
49+
50+
Create Acc, Delete Acc, Login and Logout are for test flow and are not test cases. They do not have global Locators.
51+
52+
Such and many more data entry points that appear only once and hence we do not need glonal names for them. They are hard coded as and when needed in the scripts.
53+
54+
55+
'''
56+
57+
################################################################################################################################################################################################
58+
59+
## Links on the Main UI page (Dash board). Listed in the order they appear on screen
60+
dashboard_xpath = "//div[@id='navigation']/ul/li"
61+
instances_xpath = "//div[@id='navigation']/ul/li[2]/span[2]" # Link for Instance and following as self explanatory
62+
storage_xpath = "//div[@id='navigation']/ul/li[3]/span[2]"
63+
network_xpath = "//div[@id='navigation']/ul/li[4]/span[2]"
64+
templates_xpath = "//div[@id='navigation']/ul/li[5]/span[2]"
65+
events_xpath = "//div[@id='navigation']/ul/li[6]/span[2]"
66+
projects_xpath = "//div[@id='navigation']/ul/li[7]/span[2]"
67+
accounts_xpath = "//div[@id='navigation']/ul/li[8]/span[2]"
68+
domains_xpath = "//div[@id='navigation']/ul/li[9]/span[2]"
69+
infrastructure_xpath = "//div[@id='navigation']/ul/li[10]/span[2]"
70+
globalSettings_xpath = "//div[@id='navigation']/ul/li[11]/span[2]"
71+
serviceOfferings_xpath = "//div[@id='navigation']/ul/li[12]/span[2]"
72+
73+
################################################################################################################################################################################################
74+
75+
## Instances Page
76+
## Instances Main page
77+
78+
79+
# Add Instance Button on top right corner of Instances page
80+
add_instance_xpath = "//div[2]/div/div[2]/div/div[2]/span"
81+
82+
# Add Instance Wizard next button
83+
add_instance_next_xpath = "//div[4]/div[2]/div[3]/div[3]/span"
84+
85+
# Table that lists all VM's under Instances page; General usage is to traverse through this table and search for the VM we are interested in.
86+
instances_table_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div[2]/table/tbody/tr/td/span"
87+
88+
89+
# Click any instance and following are available
90+
91+
# Click ok on confirmation pop-up box for most actions listed below
92+
actionconfirm_xpath = ("//button[@type='button']")
93+
94+
# status of VM running. Click on VM > 3rd row in table
95+
state_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div[2]/div[2]/div/div/div[2]/div/table/tbody/tr[3]/td[2]/span"
96+
97+
# Stop instance icon
98+
stopinstance_css = "a[alt=\"Stop Instance\"] > span.icon"
99+
100+
# stop instance forcefully check box available after stop instance is executed in separate pop up
101+
stopinstanceforce_id = ("force_stop")
102+
103+
# start instance icon
104+
startinstance_css = "a[alt=\"Start Instance\"] > span.icon"
105+
106+
yesconfirmation_xapth = "(//button[@type='button'])[2]"
107+
108+
109+
# Destroy instance icon
110+
destroyinstance_css = "a[alt=\"Destroy Instance\"] > span.icon"
111+
112+
#Restore Instance icon
113+
restoreinstance_css = "a[alt=\"Restore Instance\"] > span.icon"
114+
115+
# Reboot instance
116+
rebootinstance_css = "a[alt=\"Reboot Instance\"] > span.icon"
117+
118+
################################################################################################################################################################################################
119+
120+
121+
## Network Page
122+
123+
# Table that lists all Networks under Network page; General usage is to traverse through this table and search for the network we are interested in.
124+
network_networktable_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div[3]/div[2]/div/div[2]/table/tbody/tr/td/span"
125+
126+
# View IP addresses button on each network page
127+
viewIp_css="div.view-all > a > span"
128+
129+
# Acquire a new ip
130+
acquireIP_xpath="//div[2]/div/div/div[2]/span"
131+
# List of IP's within a netork table
132+
network_iptables_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div[3]/div[2]/div/div[2]/table/tbody/tr/td/span"
133+
# Configuration tab for each IP
134+
ipConfiguration_text="Configuration"
135+
# PF under configuration for each IP
136+
ip_PF = "li.portForwarding > div.view-details"
137+
138+
139+
################################################################################################################################################################################################
140+
141+
142+
## Servivce Offering Page
143+
144+
# Selects Compute offering from drop down menu
145+
Offering_compute_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[1]"
146+
147+
# Selects System offering from drop down menu
148+
Offering_system_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[2]"
149+
150+
# Selects Disk offering from drop down menu
151+
Offering_disk_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[3]"
152+
153+
# Selects Network offering from drop down menu
154+
Offering_network_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[4]"
155+
156+
# Add Offering
157+
Offering_add_xpath ="//div[3]/span"
158+
159+
# Points to tbale that lists Offerings
160+
Offering_table_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div[2]/table/tbody/tr/td/span"
161+
162+
# Edit Button
163+
Offering_edit_css = "a[alt=\"Edit\"] > span.icon"
164+
165+
# Edit name box
166+
Offering_editname_name = "name"
167+
168+
# Edit description box
169+
Offering_editdescription_name = "displaytext"
170+
171+
# Edit finished click ok
172+
Offering_editdone_css="div.button.done"
173+
174+
# delete offering button for Disk only
175+
Offering_delete_css = "a[alt=\"Delete Disk Offering\"] > span.icon"
176+
177+
# delete offering button for Compute only
178+
Offering_deletecompute_css = "a[alt=\"Delete Service Offering\"] > span.icon"
179+
180+
181+
182+
183+
################################################################################################################################################################################################
184+
185+
186+
#### Templates Page
187+
188+
# Selects Templates from drop down
189+
template_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[1]"
190+
191+
# Selects ISO from drop down
192+
iso_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[2]"
193+
194+
# Add Template
195+
AddTemplate_xpath = "//div[3]/span"
196+
197+
# Points to table where all templates are
198+
template_table_xpath ="/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div[2]/table/tbody/tr/td/span"
199+
200+
# Edit Template Button
201+
template_edit_css = "a[alt=\"Edit\"] > span.icon"
202+
203+
# Edit finished click OK
204+
template_editdone_css = "div.button.done"
205+
206+
# Delete Template button
207+
template_delete_css = "a[alt=\"Delete Template\"] > span.icon"
208+
209+
210+
################################################################################################################################################################################################
211+
212+
213+
## Login Page
214+
215+
# Username box
216+
login_username_css = "body.login > div.login > form > div.fields > div.field.username > input[name=\"username\"]" # Login>Username TextBox
217+
218+
# Password Box
219+
login_password_css = "body.login > div.login > form > div.fields > div.field.password > input[name=\"password\"]" # LoginPassword TextBox
220+
221+
# Click ok to login
222+
login_submit_css = "body.login > div.login > form > div.fields > input[type=\"submit\"]" # Login>Login Button (Submit button)
223+
224+
225+
################################################################################################################################################################################################
226+
227+
228+
## Logout
229+
logout_css = "div.cloudstack3-container > div.container > div.header > div.controls div.user > div.user-options > a[text=\"Logout\"]" # Logout
230+
# logout_css = "div#header > div#user-options > a[href='#']"

test/selenium/common/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)