-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample-taste.taste
86 lines (60 loc) · 2 KB
/
sample-taste.taste
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
/*
Taste Examples on google.com, $ style !
*/
import com.google.common.base.Predicate
import org.openqa.selenium.By
import org.openqa.selenium.Keys
import org.openqa.selenium.WebElement
import static com.pojosontheweb.taste.Taste.*
suite('Google Tests Dollar') {
add test('text search') {
webDriver.get 'http://www.google.com'
$('#lst-ib') >> sendKeys('pojos on the web')
$('button.lsb') + attrEquals('value', 'Search') >> click()
$$('#search h3.r') +
textContains('POJOs on the Web') +
at(0) +
$('a') +
textContains('POJOs on the Web') >> eval()
}
add test('text imagesF') {
webDriver.get 'http://www.google.com'
findr()
.elemList(By.tagName('a'))
.where(textEquals('Images'))
.at(0)
.click()
findr()
.elem(By.id('lst-ib'))
.sendKeys('pojos on the web', Keys.ENTER)
findr()
.elemList(By.cssSelector('a.rg_l'))
.where({ WebElement e ->
e.getAttribute('href').contains 'www.pojosontheweb.com'
} as Predicate)
.at(0)
.click()
findr()
.elemList(By.cssSelector('a.irc_vpl.irc_but'))
.where(textEquals('Visit page'))
.at(0)
.click()
findr()
.elem(By.cssSelector('div.jumbotron h1'))
.where(textEquals('POJOs on the Web!'))
.eval()
}
add test('images') {
webDriver.get 'http://www.google.com'
$$('a') + textEquals('Images') + at(0) >> click()
$('#lst-ib') >> sendKeys('pojos on the web', Keys.ENTER)
$$('a.rg_l') + { WebElement e ->
e.getAttribute('href').contains 'www.pojosontheweb.com'
} + at(0) >> click()
$$('a.irc_vpl.irc_but') +
textEquals('Visit page') +
at(0) >> click()
$('div.jumbotron h1') +
textEquals('POJOs on the Web!') >> eval()
}
}