@@ -3,16 +3,21 @@ if(identical(TRUE, getOption("seleniumPipes_SL"))){
3
3
# sauce labs test
4
4
pv <- packageVersion(" seleniumPipes" )
5
5
slFlags <- list (name = " seleniumPipes-test-suite"
6
- , build = sum(unlist(pv )* 10 ^ (3 - seq_along(unlist(pv )))) # 1.2.1 for example 121
6
+ , build = sum(unlist(pv )* 10 ^ (3 - seq_along(unlist(pv ))))
7
7
, tags = list (" api-example" )
8
- , " custom-data" = list (release = do.call(paste , list (pv , collapse = " ." )))
8
+ , " custom-data" =
9
+ list (release = do.call(paste ,
10
+ list (pv , collapse = " ." ))
11
+
12
+ )
9
13
)
10
14
selOptions <- getOption(" seleniumPipes_selOptions" )
11
15
selOptions $ extraCapabilities <- c(selOptions $ extraCapabilities , slFlags )
12
16
options(seleniumPipes_selOptions = selOptions )
13
17
}
14
18
15
- source(file.path(find.package(" seleniumPipes" ), " Saucetests" , ' setup.R' ), local = TRUE )
19
+ source(file.path(find.package(" seleniumPipes" ), " Saucetests" , ' setup.R' ),
20
+ local = TRUE )
16
21
on.exit(remDr %> % deleteSession())
17
22
18
23
# 1
@@ -44,7 +49,8 @@ test_that("FindElementsByXPath", {
44
49
test_that(" FindElementByXpathThrowNoSuchElementException" , {
45
50
expect_error(
46
51
findElementText <- remDr %> % go(loadPage(" simpleTest" )) %> %
47
- findElement(using = " xpath" , " //h4" , retry = FALSE ) %> % getElementText()
52
+ findElement(using = " xpath" , " //h4" , retry = FALSE ) %> %
53
+ getElementText()
48
54
)
49
55
expect_equal(7 , errorContent()$ status )
50
56
}
@@ -111,18 +117,22 @@ test_that("FindElementByXpathInElementContext", {
111
117
test_that(" FindElementByXpathInElementContextNotFound" , {
112
118
expect_error(remDr %> % go(loadPage(" nestedElements" )) %> %
113
119
findElement(using = " name" , " form2" ) %> %
114
- findElementFromElement(using = " xpath" , " div" , retry = FALSE ))
120
+ findElementFromElement(using = " xpath" , " div" ,
121
+ retry = FALSE ))
115
122
expect_equal(7 , errorContent()$ status )
116
123
}
117
124
)
118
125
119
126
# 15
120
127
test_that(" ShouldBeAbleToEnterDataIntoFormFields" , {
121
128
elem <- remDr %> % go(loadPage(" xhtmlTest" )) %> %
122
- findElement(using = " xpath" , " //form[@name='someForm']/input[@id='username']" ) %> %
129
+ findElement(using = " xpath" ,
130
+ " //form[@name='someForm']/input[@id='username']" ) %> %
123
131
elementClear() %> %
124
132
elementSendKeys(" some text" )
125
- elem <- remDr %> % findElement(using = " xpath" , " //form[@name='someForm']/input[@id='username']" )
133
+ elem <- remDr %> %
134
+ findElement(using = " xpath" ,
135
+ " //form[@name='someForm']/input[@id='username']" )
126
136
expect_equal(" some text" , elem %> % getElementAttribute(" value" ))
127
137
}
128
138
)
@@ -153,8 +163,8 @@ test_that("SwitchToWindow", {
153
163
# see https://code.google.com/p/selenium/issues/detail?id=3693
154
164
# return()
155
165
# }
156
- title_1 = " XHTML Test Page"
157
- title_2 = " We Arrive Here"
166
+ title_1 <- " XHTML Test Page"
167
+ title_2 <- " We Arrive Here"
158
168
159
169
remDr %> % go (loadPage(" xhtmlTest" )) %> %
160
170
findElement(using = " link text" , " Open new window" ) %> % elementClick()
@@ -167,13 +177,15 @@ test_that("SwitchToWindow", {
167
177
chk <- tryCatch({
168
178
windows <- unlist(remDr %> % getWindowHandles(retry = FALSE ))
169
179
currentWindow <- remDr %> % getWindowHandle(retry = FALSE )
170
- remDr %> % closeWindow() %> % switchToWindow(windows [! windows %in% currentWindow ])
180
+ remDr %> % closeWindow() %> %
181
+ switchToWindow(windows [! windows %in% currentWindow ])
171
182
}, error = function (e ) e )
172
183
if (inherits(chk , " simpleError" )){
173
184
# try old functions
174
185
windows <- unlist(remDr %> % getWindowHandlesOld )
175
186
currentWindow <- remDr %> % getWindowHandleOld
176
- remDr %> % closeWindow() %> % switchToWindow(windows [! windows %in% currentWindow ])
187
+ remDr %> % closeWindow() %> %
188
+ switchToWindow(windows [! windows %in% currentWindow ])
177
189
}
178
190
expect_equal(title_1 , remDr %> % getTitle )
179
191
}
@@ -192,19 +204,22 @@ test_that("IsEnabled", {
192
204
elem <- remDr %> % go(loadPage(" formPage" )) %> %
193
205
findElement(using = " xpath" , " //input[@id='working']" )
194
206
expect_true(elem %> % isElementEnabled )
195
- elem <- remDr %> % findElement(using = " xpath" , " //input[@id='notWorking']" )
207
+ elem <- remDr %> % findElement(using = " xpath" ,
208
+ " //input[@id='notWorking']" )
196
209
expect_false(elem %> % isElementEnabled )
197
210
}
198
211
)
199
212
200
213
# 24-27
201
214
test_that(" IsSelectedAndToggle" , {
202
- if (rdBrowser == ' chrome' && package_version(remDr $ sessionInfo $ version )$ major < 16 ){
215
+ if (rdBrowser == ' chrome' &&
216
+ package_version(remDr $ sessionInfo $ version )$ major < 16 ){
203
217
return (" deselecting preselected values only works on chrome >= 16" )
204
218
}
205
219
elem <- remDr %> % go(loadPage(" formPage" )) %> %
206
220
findElement(using = " id" , " multi" )
207
- option_elems <- elem %> % findElementsFromElement(using = " xpath" , " option" )
221
+ option_elems <- elem %> %
222
+ findElementsFromElement(using = " xpath" , " option" )
208
223
Sys.sleep(2 )
209
224
expect_true(option_elems [[1 ]] %> % isElementSelected )
210
225
option_elems [[1 ]] %> % elementClick
@@ -220,7 +235,6 @@ test_that("IsSelectedAndToggle", {
220
235
# 28-30
221
236
test_that(" Navigate" , {
222
237
# if(rdBrowser == 'safari'){
223
- # see http://code.google.com/p/selenium/issues/detail?id=3771&can=1&q=browser%3DSafari%20component%3DWebDriver%20status%3ANew%2CAccepted%2CWorkingAsIntended%2CWontFix%2CNotFeasible&colspec=ID%20Stars%20Type%20Status%20Priority%20Owner%20Summary%20Browser%20Component
224
238
# return()
225
239
# }
226
240
@@ -248,7 +262,8 @@ test_that("GetImplicitAttribute", {
248
262
findElements(using = " xpath" , " //option" )
249
263
expect_true(length(elems ) > = 3 )
250
264
for (x in seq(4 )){
251
- expect_equal(x - 1 , as.integer(elems [[x ]] %> % getElementAttribute(" index" )))
265
+ expect_equal(x - 1 , as.integer(elems [[x ]] %> %
266
+ getElementAttribute(" index" )))
252
267
}
253
268
}
254
269
)
@@ -272,7 +287,8 @@ test_that("ExecuteSimpleScript", {
272
287
test_that(" ExecuteScriptAndReturnElement" , {
273
288
chk <- tryCatch({
274
289
elem <- remDr %> % go(loadPage(" xhtmlTest" )) %> %
275
- executeScript(" return document.getElementById('id1');" , retry = FALSE )
290
+ executeScript(" return document.getElementById('id1');" ,
291
+ retry = FALSE )
276
292
}, error = function (e ) e )
277
293
if (inherits(chk , " simpleError" )){
278
294
# try old functions
@@ -286,14 +302,16 @@ test_that("ExecuteScriptAndReturnElement", {
286
302
# 39
287
303
test_that(" ExecuteScriptWithArgs" , {
288
304
chk <- tryCatch({
305
+ jS <- " return arguments[0] == 'fish' ? 'fish' : 'not fish';"
289
306
result <- remDr %> % go(loadPage(" xhtmlTest" )) %> %
290
- executeScript(" return arguments[0] == 'fish' ? 'fish' : 'not fish'; " , list (" fish" )
307
+ executeScript(jS , list (" fish" )
291
308
, retry = FALSE )
292
309
}, error = function (e ) e )
293
310
if (inherits(chk , " simpleError" )){
294
311
# try old functions
312
+ jS <- " return arguments[0] == 'fish' ? 'fish' : 'not fish';"
295
313
result <- remDr %> % go(loadPage(" xhtmlTest" )) %> %
296
- executeScriptOld(" return arguments[0] == 'fish' ? 'fish' : 'not fish'; " , list (" fish" ))
314
+ executeScriptOld(jS , list (" fish" ))
297
315
}
298
316
expect_equal(" fish" , result )
299
317
}
@@ -320,14 +338,19 @@ test_that("ExecuteScriptWithElementArgs", {
320
338
chk <- tryCatch({
321
339
button <- remDr %> % go(loadPage(" javascriptPage" )) %> %
322
340
findElement(using = " id" , " plainButton" )
323
- appScript <- " arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];"
324
- result <- remDr %> % executeScript(appScript , list (button ), retry = FALSE )
341
+ appScript <-
342
+ " arguments[0]['flibble'] = arguments[0].getAttribute('id');
343
+ return arguments[0]['flibble'];"
344
+ result <- remDr %> % executeScript(appScript , list (button ),
345
+ retry = FALSE )
325
346
}, error = function (e ) e )
326
347
if (inherits(chk , " simpleError" )){
327
348
# try old functions
328
349
button <- remDr %> % go(loadPage(" javascriptPage" )) %> %
329
350
findElement(using = " id" , " plainButton" )
330
- appScript <- " arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];"
351
+ appScript <-
352
+ " arguments[0]['flibble'] = arguments[0].getAttribute('id');
353
+ return arguments[0]['flibble'];"
331
354
result <- remDr %> % executeScriptOld(appScript , list (button ))
332
355
}
333
356
expect_equal(" plainButton" , result )
@@ -345,8 +368,10 @@ test_that("FindElementsByPartialLinkText", {
345
368
# 43-44
346
369
test_that(" IsElementDisplayed" , {
347
370
visible <- remDr %> % go(loadPage(" javascriptPage" )) %> %
348
- findElement(using = " id" , " displayed" ) %> % getElementCssValue(" visibility" )
349
- not_visible <- remDr %> % findElement(using = " id" , " hidden" )%> % getElementCssValue(" visibility" )
371
+ findElement(using = " id" , " displayed" ) %> %
372
+ getElementCssValue(" visibility" )
373
+ not_visible <- remDr %> % findElement(using = " id" , " hidden" )%> %
374
+ getElementCssValue(" visibility" )
350
375
expect_identical(visible , " visible" )
351
376
expect_identical(not_visible , " hidden" )
352
377
}
@@ -365,16 +390,16 @@ test_that("MoveWindowPosition", {
365
390
getWindowPosition()
366
391
# note can't test 0,0 since some OS's dont allow that location
367
392
# because of system toolbars
368
- new_x = 50
369
- new_y = 50
393
+ new_x <- 50
394
+ new_y <- 50
370
395
if (loc [[' x' ]] == new_x ){
371
396
new_x <- new_x + 10
372
397
}
373
398
if (loc [' y' ] == new_y ){
374
399
new_y <- new_y + 10
375
400
}
376
401
remDr %> % setWindowPosition(new_x , new_y )
377
- loc = remDr %> % getWindowPosition()
402
+ loc <- remDr %> % getWindowPosition()
378
403
# change test to be within 10 pixels
379
404
expect_less_than(abs(loc [[' x' ]] - new_x ), 10 )
380
405
expect_less_than(abs(loc [[' y' ]] - new_y ), 10 )
0 commit comments