-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathtest_TWP52.py
More file actions
213 lines (164 loc) · 6.65 KB
/
test_TWP52.py
File metadata and controls
213 lines (164 loc) · 6.65 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
def test_l52_1(page):
page.goto("lectures/TWP52/TWP52_en.html")
# Run the exercise
page.click("#ac_l52_1a_en >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('iframe')
# Get the iframe
frame = page.frame(url="about:srcdoc")
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
# Interact with the iframe
frame.click("input")
frame.fill("input", "Lisbon")
frame.click(":nth-match(input, 2)")
frame.fill(":nth-match(input, 2)", "Great Place!")
frame.click(":nth-match(input, 3)")
frame.fill(":nth-match(input, 3)", "Nico")
frame.click("text=Save")
def test_l52_2(page):
page.goto("lectures/TWP52/TWP52.html")
# Run the exercise
page.click("#ac_l52_1a >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('iframe')
# Get the iframe
frame = page.frame(url="about:srcdoc")
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
# Interact with the iframe
frame.click("input")
frame.fill("input", "Lisbon")
frame.click(":nth-match(input, 2)")
frame.fill(":nth-match(input, 2)", "Great Place!")
frame.click(":nth-match(input, 3)")
frame.fill(":nth-match(input, 3)", "Nico")
frame.click("text=Guardar")
def test_l52_3(page):
page.goto("lectures/TWP52/TWP52_en.html")
# Click #ac_l52_1b_en >> text=Run
page.click("#ac_l52_1b_en >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('//*[@id="ac_l52_1b_en"]/div/div[4]/iframe')
# Get the iframe
iframe = page.query_selector('//*[@id="ac_l52_1b_en"]/div/div[4]/iframe')
frame = iframe.content_frame()
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
# Click input[name="destination"]
frame.click("input[name=\"destination\"]")
def test_l52_4(page):
page.goto("lectures/TWP52/TWP52.html")
# Click #ac_l52_1b >> text=Run
page.click("#ac_l52_1b >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('//*[@id="ac_l52_1b"]/div/div[4]/iframe')
# Get the iframe
iframe = page.query_selector('//*[@id="ac_l52_1b"]/div/div[4]/iframe')
frame = iframe.content_frame()
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
# Click input[name="destination"]
frame.click("input[name=\"destino\"]")
def test_l52_5(page):
page.goto("lectures/TWP52/TWP52_en.html")
# Click #ac_l52_1c_en >> text=Run
page.click("#ac_l52_1c_en >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('//*[@id="ac_l52_1c_en"]/div/div[4]/iframe')
# Get the iframe
iframe = page.query_selector('//*[@id="ac_l52_1c_en"]/div/div[4]/iframe')
frame = iframe.content_frame()
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
page.frame(url="about:srcdoc").click("input")
# Fill input
page.frame(url="about:srcdoc").fill("input", "Mumbai")
# Click :nth-match(input, 2)
page.frame(url="about:srcdoc").click(":nth-match(input, 2)")
# Fill :nth-match(input, 2)
page.frame(url="about:srcdoc").fill(":nth-match(input, 2)", "Great City!")
# Click textarea
page.frame(url="about:srcdoc").click("textarea")
# Fill textarea
page.frame(url="about:srcdoc").fill("textarea", "Taj Hotel")
# Click text=Save
page.frame(url="about:srcdoc").click("text=Save")
def test_l52_6(page):
page.goto("lectures/TWP52/TWP52.html")
# Click #ac_l52_1c >> text=Run
page.click("#ac_l52_1c >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('//*[@id="ac_l52_1c"]/div/div[4]/iframe')
# Get the iframe
iframe = page.query_selector('//*[@id="ac_l52_1c"]/div/div[4]/iframe')
frame = iframe.content_frame()
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
page.frame(url="about:srcdoc").click("input")
# Fill input
page.frame(url="about:srcdoc").fill("input", "Mumbai")
# Click :nth-match(input, 2)
page.frame(url="about:srcdoc").click(":nth-match(input, 2)")
# Fill :nth-match(input, 2)
page.frame(url="about:srcdoc").fill(":nth-match(input, 2)", "Great City!")
# Click textarea
page.frame(url="about:srcdoc").click("textarea")
# Fill textarea
page.frame(url="about:srcdoc").fill("textarea", "Taj Hotel")
# Click text=Save
page.frame(url="about:srcdoc").click("text=Guardar")
def test_l52_7(page):
page.goto("lectures/TWP52/TWP52_en.html")
# Click #ac_l52_1d_en >> text=Run
page.click("#ac_l52_1d_en >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('//*[@id="ac_l52_1d_en"]/div/div[4]/iframe')
# Get the iframe
iframe = page.query_selector('//*[@id="ac_l52_1d_en"]/div/div[4]/iframe')
frame = iframe.content_frame()
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
# Select Option 2
page.frame(url="about:srcdoc").select_option("select", "Option 2")
# Click input
page.frame(url="about:srcdoc").click("input")
# Fill input
page.frame(url="about:srcdoc").fill("input", "Hey there")
# Click :nth-match(input, 2)
page.frame(url="about:srcdoc").click(":nth-match(input, 2)")
# Fill :nth-match(input, 2)
page.frame(url="about:srcdoc").fill(":nth-match(input, 2)", "Steve")
# Click text=Save
page.frame(url="about:srcdoc").click("text=Save")
def test_l52_8(page):
page.goto("lectures/TWP52/TWP52.html")
# Click #ac_l52_1d_en >> text=Run
page.click("#ac_l52_1d >> *css=button >> text=Run")
# Wait for the iframe to load
page.wait_for_selector('//*[@id="ac_l52_1d"]/div/div[4]/iframe')
# Get the iframe
iframe = page.query_selector('//*[@id="ac_l52_1d"]/div/div[4]/iframe')
frame = iframe.content_frame()
# Check if the iframe was found
if frame is None:
raise Exception("Could not find iframe")
# Select Option 2
page.frame(url="about:srcdoc").select_option("select", "Opción 2")
# Click input
page.frame(url="about:srcdoc").click("input")
# Fill input
page.frame(url="about:srcdoc").fill("input", "Hey there")
# Click :nth-match(input, 2)
page.frame(url="about:srcdoc").click(":nth-match(input, 2)")
# Fill :nth-match(input, 2)
page.frame(url="about:srcdoc").fill(":nth-match(input, 2)", "Steve")
# Click text=Save
page.frame(url="about:srcdoc").click("text=Guardar")