Selenium Overview
-
Upload
aacharya-rakesh-tiwari -
Category
Documents
-
view
20 -
download
0
Transcript of Selenium Overview
![Page 1: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/1.jpg)
Selenium Overview
![Page 2: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/2.jpg)
Today's Session Covers
» Selenium Origins
» Selenium – What is it?
» Types of Selenium
» Selenium IDE
» Selenese Test Cases and Test Suites
» Selenium RC
» Selenium Core
» Element Locators
![Page 3: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/3.jpg)
Selenium Origins
» Selenium is a key mineral which protects the body from Mercury toxicity
» Many of Selenium developers knew Mercury tools very well
![Page 4: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/4.jpg)
What is Selenium
» Selenium is a web test tool that runs in the browser
» Selenium is implemented completely with Browser technology –
Javascript , DHTML , Frames
» Works with virtually any Javascript-enabled browser
![Page 5: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/5.jpg)
Selenium supports
» Browsers» Firefox» IE» Safari» Opera» Others – Partially supported
» Operating System» Windows» Linux» Solaris
![Page 6: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/6.jpg)
Javascript
» Selenium is written in Javascript
» Javascript is how AJAX applications are written, so Selenium can
test them too
![Page 7: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/7.jpg)
Types of Selenium
» Selenium Core – The main component of Selenium
» Selenium RC – A scripting layer over Selenium Core
» Selenium IDE – a Firefox extension with record / playback
functionality
» Selenium Grid - distribute your tests on multiple machines so that
you can run your tests in parallel
![Page 8: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/8.jpg)
Selenium IDE
» Selenium IDE adds a layer of Record / Playback to Selenium
» Is available for Firefox only
![Page 9: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/9.jpg)
Selenium IDE
![Page 10: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/10.jpg)
Selenese Test Case
Command Target Value
open /jobmining/
type queryTitle qa
select ct_category label=Banking
clickAndWait Submit01
clickAndWait link=sqa
![Page 11: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/11.jpg)
Checkpoints
Of course, scripts wouldn’t be tests if they didn’t check something» assert* tests fail the test immediately» verify* tests keep track of results and continue the script regardless
verifyTextPresent Job Description dfgdg
asserTextPresent Job Requirements sdrfasf
![Page 12: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/12.jpg)
Locators
Selenium identifies what a component is through the use of a locator
» link=name» dom=document.images[56]» xpath=//table[@id='table1']//tr[4]/td[2]» css=a[href="#id3"]
![Page 13: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/13.jpg)
Playback
Playback of a single script is handled through the IDE
» Run – Go as fast as the script can process
» Walk – Slows down the execution
» Step – Executes the next step
![Page 14: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/14.jpg)
Test Suites
In order to run multiple scripts, you need to chain them together in a Test Suite
» Just another html table
» Runs inside Firefox, but not in S-IDE
» Saved in the same directory as the tests that are included in it
![Page 15: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/15.jpg)
Test Suites
<table> <tr> <td>Job Search test suite</td> </tr> <tr> <td><a target="testFrame" href=“selenium-ide-01.html">Job
Search</a></td> </tr></table>
![Page 16: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/16.jpg)
Selenium RC
Selenium IDE is great for quick recording of tests, but it somewhat
lacks for power
Selenium RC gives you the ability to drive Selenium from a real
programming language (Java, Perl, Python, Ruby,C# and PHP)
![Page 17: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/17.jpg)
Why do you want a real language?
By using Selenium inside a full fledged language you can do the following
» Check the database
» Control external services
» Launch multiple windows
» Run multiple browsers in parallel
![Page 18: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/18.jpg)
Selenium RC
![Page 19: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/19.jpg)
Proxy
Because the commands for Selenium RC are embedded in a script, a proxy is needed to control the browser.
![Page 20: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/20.jpg)
Same Origin
Prevents a document or script loaded from one origin from getting or
setting properties of a document from a different origin – Mozilla
security documentation
In other words, cannot work across server boundaries
![Page 21: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/21.jpg)
Selenium Core
» Selenium Core is used by both Selenium IDE and RC
» Runs test suites on the same server to avoid the Same Origin
problem
» Don’t have same flexibility as RC, but tests and code under test is
in the same spot
![Page 22: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/22.jpg)
Selenium Grid
» Selenium Grid allows you to run multiple instances of Selenium
Remote Control in parallel.
» It allows you to easily run multiple tests in parallel, on multiple
machines in an heterogeneous environment.
![Page 23: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/23.jpg)
Selenium Grid
![Page 24: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/24.jpg)
Element Locators
» id=id
Select the element with the specified @id attribute.
» name=name
Select the first element with the specified @name attribute.
» identifier=id
Select the element with the specified @id attribute
If no match is found, select the first element whose @name attribute is id.
» dom=javascriptExpression
Find an element using JavaScript traversal of the HTML Document
Object Model. DOM locators must begin with "document."
dom=document.forms['myForm'].myDropdown
dom=document.images[56]
![Page 25: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/25.jpg)
Element Locators
» xpath=xpathExpression
Locate an element using an XPath expression. XPath locators must
begin with "//".
xpath=//img[@alt='The image alt text']
xpath=//table[@id='table1']//tr[4]/td[2]
» link=textPattern
Select the link (anchor) element which contains text matching the specified pattern.
link=The link text
» css=cssSelectorSyntax
Select the element using css selectors.
css=a[href="#id3"]
css=span#firstChild + span
![Page 26: Selenium Overview](https://reader036.fdocuments.in/reader036/viewer/2022062309/55cf9969550346d0339d46a0/html5/thumbnails/26.jpg)
Questions???