-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
313 lines (248 loc) · 9.63 KB
/
index.html
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Let's talk testing with Selenium</title>
<meta name="description" content="Selenium testing framework">
<meta name="author" content="Anisha Narang">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" media="all" href="css/reveal.min.css">
<link rel="stylesheet" media="all" href="css/theme/serif.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<link media="print" rel="stylesheet" href="lib/css/print/pdf.css">
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>Let's talk testing with Selenium</h2>
<h3></h3>
<p>
<small>Created by Anisha Narang | <a href = "http://www.redhat.com">Red Hat Inc.</a></small></p>
<p> <a href="http://in.pycon.org/2013/">PyCon India 2013, Bangalore </a></p>
</section>
<section>
<h2><strong>Why Testing?</strong></h2>
</section>
<section>
<h2><strong> Test Automation</strong></h2>
<!--<p style="color: green; font-size: 100px"><strong><span color="yellow">Test Automation</span></strong></p>-->
<!--<h2><strong>Test Automation</strong></h2>-->
</section>
<section>
<h3>... is use of testing tool to:</h3>
<!--Test automation is the use of testing tool to:-->
<ul>
<li>To control the execution of tests</li>
<li>To compare the actual outcomes to expected outcomes</li>
<li>To report the test status(PASS/FAIL)</li>
</ul>
</section>
<section>
<h2><img width="75" height="75" src="./images/selenium-logo.png"><strong>Selenium</strong></h2>
<ul>
<li>Selenium automates web browsers</li>
<li>Can be controlled by many programming languages and testing frameworks</li>
</ul>
<blockquote >
<pre style= "font-size: 22px">Programming language : python</pre>
<pre style= "font-size: 22px">Testing framework : unittest</pre>
</blockquote>
<p> </p>
<p><a href="http://selenium-python.readthedocs.org/en/latest/index.html#">http://selenium-python.readthedocs.org</a></p>
</section>
<section>
<h2><strong>Test Automation with Selenium</strong></h2>
<p>
<ul>
<li>Regression testing</li>
<li>Validate the application flow</li>
<li>Test suites</li>
<li>Report generation</li>
</ul>
</p>
</section>
<section>
<h2><strong>How to start?</strong></h2>
<ul>
<li class="fragment">Install Selenium
<p><small><code>pip install selenium</code></small></p></li>
<li class="fragment">Record and Play with Selenium IDE </li>
</ul>
</section>
<section>
<img src="./images/ide.png">
</section>
<section>
<img src="./images/ide_with_format.png">
</section>
<section>
<img src="./images/ide_python.png">
</section>
<section>
<h2>Selenium script looks like? </h2>
<pre><code data-trim>
#!/usr/bin/env python
from selenium import webdriver
import unittest
Class Test(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.get("www.example.com")
def test_case(self):
#write your test case here
def tearDown(self):
self.driver.quit()
if __name__ == "__main__":
unittest.main()
</code></pre>
</section>
<section>
<h2>Building an <img class="approach" height="150" src="./images/approach.png"></h2>
<ol>
<li>Understand the functionality</li>
<li>Write test plan and test cases</li>
<li>Decide which test cases to automate</li>
<li>Inspect the UI elements accordingly</li>
<li>Start writing your test script</li>
</ol>
</section>
<section >
<h2>To automate<strong>What?</strong></h2>
<!--img height="600" width="1000" src="./images/common.png"-->
</section>
<section>
<h2><strong>Some sample code...</strong></h2>
</section>
<section>
<h3>Search</h3>
<pre><code>
#test_data.json
[
{"name": "echo","id": 1},{"name": "print","id": 2},{"name": "hello world","id": 3}
]
</code></pre>
<pre><code>
def test_search():
with open(“test_data.json”) as data_file:
data_text = json.load(data_file)
for each in data_text:
search_text = each["name"]
var = driver.find_element_by_id("search_box")
var.clear()
var.send_keys(search_text)
driver.find_element_by_name("search").click()
element = driver.find_elements_by_class_name('hl')
element_text = {z.text.lower() for z in element}
for e in element_text:
self.assertEqual(search_text.lower(), e, "Search result does not match")
</code></pre>
</section>
<section>
<h3>Checkbox selection</h3>
<pre><code>
def test_checkbox():
try:
checkbox = driver.find_element_by_id("id_1")
self.assertTrue(checkbox.is_selected(),"Incorrect filter selection")
self.assertTrue(checkbox.is_enabled(),"Checkbox is disabled")
except NoSuchElementException:
logging.info("No element present for checkbox")
</code></pre>
</section>
<section>
<h3>Pagination</h3>
<pre><code>
def test_pagination():
element=driver.find_element_by_class_name('pagination')
regexp= r"[A-Za-z0-9]+"
page_numbers = re.findall(regexp,element.text)
prev_element = driver.find_element_by_class_name('disabled')
prev_element = prev_element.text
self.assertEqual(prev_element, page_numbers[0], "'Prev' NOT disabled")
#similarly verify the next element
</pre></code>
</section>
<section>
<h2><strong>How to maintain your scripts?</strong></h2>
<!--ul>
<li>Structure your test project</li>
<li>Decide format for input test data</li>
<li>Keep the code DRY</li>
<li>Use logging module to keep track of the events taking place during the test run</li>
</ul-->
</section>
<section>
<h2><strong>Test reports</strong></h2>
<p> </p>
<p>Generate reports using <a href="https://github.com/tungwaiyip/HTMLTestRunner">HTMLTestRunner.py</a></p>
</section>
<section>
<img src="./images/report.png">
</section>
<section>
<h1><strong>Demo time</strong></h1>
<p> </p>
<p>Code available at: <a href= "https://github.com/anarang/fusion">https://github.com/anarang/fusion</a></p>
</section>
<section>
<h2><strong>Best practices</strong></h2>
<!--ul>
<li>Decide which test cases to automate</li>
<li>Create good quality test data</li>
<li>Design stable logic for test scripts</li>
<li>Include code to handle selenium errors which may occur</li>
<li>Generate test reports </li>
</ul-->
</section>
<section data-background="black">
<img src="./images/questions.png" width="637" height="600" />
</section>
<section>
<h2><strong>Thank You</strong><img src="./images/smiley.png" height="100" width= "100"></h2>
<p><a href =
"http://www.twitter.com/anisha_narang">@anisha_narang</a> | [email protected]</p>
<p>Slides available at: <a href= "http://pyselenium-anisha.rhcloud.com/#/">http://pyselenium-anisha.rhcloud.com</a></p>
<p><a href="https://github.com/anarang/pyselenium">http://goo.gl/UbAOW2</a></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/leap/leap.js', async: true }
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>