tellurium_driver 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tellurium_driver.rb +40 -10
- metadata +1 -1
data/lib/tellurium_driver.rb
CHANGED
@@ -10,9 +10,13 @@ class TelluriumDriver
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
#@sets up this instance of TelluriumDriver
|
15
|
+
#@param [String] browser, "chrome","firefox", or "internet explorer"
|
16
|
+
#@param [Integer] version, the version of the browser. nil for firefox or chrome, or "local" to run locally
|
17
|
+
#@param hub_ip [String] the IP address of the Selenium Grid hub to test on
|
18
|
+
#@param [Integer] timeout, the timeout to use on test
|
14
19
|
def initialize(*args)
|
15
|
-
|
16
20
|
browser, version,hub_ip,timeout = args
|
17
21
|
timeout = 120 unless timeout
|
18
22
|
@wait = Selenium::WebDriver::Wait.new(:timeout=>timeout)
|
@@ -69,10 +73,13 @@ class TelluriumDriver
|
|
69
73
|
@driver.send sym,*args,&block
|
70
74
|
end
|
71
75
|
|
76
|
+
#@param [String] url, the url to point the driver at
|
72
77
|
def go_to(url)
|
73
78
|
driver.get url
|
74
79
|
end
|
75
80
|
|
81
|
+
#Waits for the title to change after going to a url
|
82
|
+
#@param [String] url, the url to go to
|
76
83
|
def go_to_and_wait_to_load(url)
|
77
84
|
current_name = driver.title
|
78
85
|
driver.get url
|
@@ -80,6 +87,7 @@ class TelluriumDriver
|
|
80
87
|
#wait until the current title changes to see that you're at a new url
|
81
88
|
@wait.until { driver.title != current_name }
|
82
89
|
end
|
90
|
+
|
83
91
|
#takes a url, the symbol of what you wait to exist and the id/name/xpath, whatever of what you want to wait to exist
|
84
92
|
def load_website_and_wait_for_element(url,arg1,id)
|
85
93
|
current_name = driver.title
|
@@ -87,10 +95,10 @@ class TelluriumDriver
|
|
87
95
|
|
88
96
|
@wait.until { driver.title != current_name and driver.find_elements(arg1, id).size > 0 }
|
89
97
|
end
|
90
|
-
|
91
|
-
#
|
92
|
-
|
93
|
-
|
98
|
+
|
99
|
+
#clicks one element and waits for another one to change it's value.
|
100
|
+
#@param [String] id_to_click, the id you want to click
|
101
|
+
#@param [String] id_to_change you
|
94
102
|
def click_and_wait_to_change(id_to_click,id_to_change,value)
|
95
103
|
element_to_click = driver.find_element(:id, id_to_click)
|
96
104
|
element_to_change = driver.find_element(:id, id_to_change)
|
@@ -100,11 +108,15 @@ class TelluriumDriver
|
|
100
108
|
@wait.until { element_to_change.attribute(value.to_sym) != current_value }
|
101
109
|
end
|
102
110
|
|
111
|
+
#Fills in a value for form selectors
|
112
|
+
#@param [Symbol] sym, usually :id, :css, or :name
|
113
|
+
#@param [String] selector_value, the value to set the selector to
|
103
114
|
def click_selector(sym,id,selector_value)
|
104
115
|
option = Selenium::WebDriver::Support::Select.new(driver.find_element(sym.to_sym,id))
|
105
116
|
option.select_by(:text, selector_value)
|
106
117
|
end
|
107
118
|
|
119
|
+
#Fills out a selector and waits for another id to change
|
108
120
|
def click_selector_and_wait(id_to_click,selector_value,id_to_change,value)
|
109
121
|
element_to_change = driver.find_element(:id => id_to_change)
|
110
122
|
current_value = element_to_change.attribute(value.to_sym)
|
@@ -115,6 +127,8 @@ class TelluriumDriver
|
|
115
127
|
@wait.until { element_to_change.attribute(value.to_sym) != current_value }
|
116
128
|
end
|
117
129
|
|
130
|
+
#Waits for an element to be displayed
|
131
|
+
#@param [SeleniumWebdriver::Element]
|
118
132
|
def wait_for_element(element)
|
119
133
|
@wait.until {
|
120
134
|
bool = false
|
@@ -129,6 +143,9 @@ class TelluriumDriver
|
|
129
143
|
}
|
130
144
|
end
|
131
145
|
|
146
|
+
#Waits for the element with specified identifiers to disappear
|
147
|
+
#@param [Symbol] sym
|
148
|
+
#@param [String] id
|
132
149
|
def wait_to_disappear(sym,id)
|
133
150
|
@wait.until {
|
134
151
|
element_arr = driver.find_elements(sym,id)
|
@@ -136,6 +153,8 @@ class TelluriumDriver
|
|
136
153
|
}
|
137
154
|
end
|
138
155
|
|
156
|
+
#waits for an element to disappear
|
157
|
+
#@param [SeleniumWebdriver::Element] element
|
139
158
|
def wait_for_element_to_disappear(element)
|
140
159
|
@wait.until {
|
141
160
|
begin
|
@@ -145,14 +164,18 @@ class TelluriumDriver
|
|
145
164
|
end
|
146
165
|
}
|
147
166
|
end
|
148
|
-
|
167
|
+
|
168
|
+
#@param [Symbol] sym
|
169
|
+
#@param [String] id, the string associated with the symbol to identify the elementw
|
149
170
|
def wait_to_appear(sym,id)
|
150
171
|
@wait.until {
|
151
172
|
element_arr = driver.find_elements(sym,id)
|
152
173
|
element_arr.size > 0 and element_arr[0].displayed? #wait until the element both exists and is displayed
|
153
174
|
}
|
154
175
|
end
|
155
|
-
|
176
|
+
|
177
|
+
# to change. (Example, I click start-application and wait for the next dialogue
|
178
|
+
# box to not be hidden)
|
156
179
|
def wait_and_click(sym, id)
|
157
180
|
found_element = false
|
158
181
|
|
@@ -181,7 +204,9 @@ class TelluriumDriver
|
|
181
204
|
end
|
182
205
|
|
183
206
|
end
|
184
|
-
|
207
|
+
|
208
|
+
# Waits for an element to be displayed and click it
|
209
|
+
#@param [SeleniumWebdriver::Element]
|
185
210
|
def wait_for_element_and_click(element)
|
186
211
|
wait_for_element(element)
|
187
212
|
|
@@ -197,7 +222,8 @@ class TelluriumDriver
|
|
197
222
|
|
198
223
|
end
|
199
224
|
|
200
|
-
#hovers where the element is and clicks. Workaround for timeout on click that happened with the new update to the showings app
|
225
|
+
#hovers where the element is and clicks. Workaround for timeout on click that happened with the new update to the showings app
|
226
|
+
#@param [SeleniumWebdriver::Element] element OR can take sym,id
|
201
227
|
def hover_click(*args)
|
202
228
|
if args.size == 1
|
203
229
|
driver.action.click(element).perform
|
@@ -208,6 +234,10 @@ class TelluriumDriver
|
|
208
234
|
|
209
235
|
end
|
210
236
|
|
237
|
+
#fills an input of the given sym,id with a value
|
238
|
+
#@param [Symbol] sym
|
239
|
+
#@param [String] id
|
240
|
+
#@param [String] value
|
211
241
|
def send_keys(sym,id,value)
|
212
242
|
#self.wait_and_click(sym, id)
|
213
243
|
#driver.action.send_keys(driver.find_element(sym => id),value).perform
|