Selenium
Upcoming SlideShare
Loading in...5
×
 

Selenium

on

  • 32,317 views

These are the slides I used to introduce one of my classes to web automation using Selenium

These are the slides I used to introduce one of my classes to web automation using Selenium

Statistics

Views

Total Views
32,317
Views on SlideShare
31,726
Embed Views
591

Actions

Likes
21
Downloads
1,712
Comments
2

16 Embeds 591

http://www.slideshare.net 143
http://adam.goucher.ca 98
http://seleniumstuffs.blogspot.com 98
http://50.112.202.140 80
http://localhost 49
http://tools.taaray.com 49
http://seleniumstuffs.blogspot.in 24
http://reddyphp.wordpress.com 16
http://www.taaray.com 11
http://www.seleniumstuffs.blogspot.com 9
http://www.linkedin-ei2.com 4
http://www.scoop.it 4
http://slideshow.com 2
http://www.adam.goucher.ca 2
http://webcache.googleusercontent.com 1
http://www.slideshow.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Don't forget the Firefox plugin 'Xpath Checker', it will allow you to validate your xpath locators and see the returned results!
    Are you sure you want to
    Your message goes here
    Processing…
  • Some corrections: You can get selenium support for free from the PushToTest.com users group (see http://www.pushtotest.com/community). PushToTest uses Selenium as one of it's front end test record/playback tools along with SoapUI and others.
    You can get paid for support for Selenium and all the tools that PushToTest incorporates, including their 'TestMaker functional/performance test and production monitor tool which lets you use your tests as functional test cases, load/performance tests and production monitors. See their professional services group at http://www.pushtotest.com/services

    It's much easier to use selenium with multi data sets and test cases using testmaker than having to code all that yourself, manually.

    Pedro
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Selenium Selenium Presentation Transcript

  • Selenium Adam Goucher [email_address]
  • Lecture Objective
    • Give students an introduction to web automation using the Selenium framework.
  • What is Selenium?
    • Selenium is a web test tool that runs in the browser
    • Because it runs in the browser, it does exactly what a user does
  • What tests can Selenium do?
    • Browser compatibility – One script, many browsers
    • Regression
  • Javascript
    • Selenium is written in Javascript
    • Javascript is how AJAX applications are written, so Selenium can test them too
  • Where to get it?
    • Selenium can be downloaded and installed for free from http:// www.openqa.org
  • QTP vs. Selenium
    • QTP is not cross platform, Selenium is
    • QTP costs a lot of money, Selenium is free
    • QTP needs VBScript, Selenium has lots of language bindings
    • The default format of testing in Selenium is HTML
    • QTP can control other types of applications other than web
  • Multiple Seleniums?
    • There are 3 versions 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 IDE
    • Selenium IDE adds a layer of Record / Playback to Selenium
    • Is available for Firefox only
  • First Script link=sqa clickAndWait Submit01 clickAndWait label=Banking ct_category select qa queryTitle type /jobmining/ open Value Target Command
  • 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
    Job Requirements sdrfasf asserTextPresent Job Description dgds verifyTextPresent
  • 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"]
    • Depending on your application, there might be major performance differences
  • 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
  • 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
  • Test Suites
    • <table>
    • <tr>
    • <td>Job Search test suite</td>
    • </tr>
    • <tr>
    • <td><a target=&quot;testFrame&quot; href=“selenium-ide-01.html&quot;>Job Search</a></td>
    • </tr>
    • </table>
  • Test Suites
    • The URL has a specific format
    • chrome://selenium-ide/content/selenium/TestRunner.html?baseURL=http://your_hose:port&test=file:///c://temp/qa109/testsuite.html&auto=true&multiWindow=false
  • 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, and more)
  • Why do you want a real language?
    • By using Selenium inside a full fledged language you can do the following
    • Seed the database
    • Check the database
    • Control external services
    • Launch multiple windows
    • Run multiple browsers in parallel
    • In addition to running the actual test.
  • Proxy
    • Because the commands for Selenium RC are embedded in a script, a proxy is needed to control the browser.
  • Python
    • There are python bindings for most of the Selenium calls
    • Watch for naming differences
    • While not necessary, most use the unittest module with Selenium
    • import selenium, unittest
    • class JM(unittest.TestCase):
    • def setUp(self):
    • protocol = &quot;http&quot;
    • host = &quot;your host&quot;
    • port = your_port_number
    • self.verificationErrors = []
    • self.selenium = selenium.selenium(&quot;localhost&quot;, 4444, &quot;*chrome&quot;, &quot;%s://%s:%s&quot; % (protocol, host, port)) self.selenium.start()
    • self.selenium.open(&quot;/jobmining/&quot;)
    • def test_doSearch(self):
    • sel = self.selenium
    • sel.open(&quot;/jobmining/&quot;)
    • sel.type(&quot;queryTitle&quot;, &quot;qa&quot;)
    • sel.select(&quot;ct_category&quot;, &quot;label=Banking&quot;)
    • sel.click(&quot;Submit01&quot;)
    • sel.wait_for_page_to_load(&quot;30000&quot;)
    • sel.click(&quot;link=sqa&quot;)
    • sel.wait_for_page_to_load(&quot;30000&quot;)
    • try:
    • self.failUnless(sel.is_text_present(&quot;Job Description dgds&quot;))
    • except AssertionError, e:
    • self.verificationErrors.append(str(e))
    • def tearDown(self):
    • self.selenium.stop()
    • if __name__ == &quot;__main__&quot;:
    • unittest.main()
  • Data Driven
    • One key concept when doing automation is to recycle your scripts through data driving them
    • Use the underlying language you are using Selenium RC with to handle most of it for you
  • 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 boundries
  • 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
  • Tips
    • Start and stop your script from the same spot
    • Record your script in S-IDE, then use it as a base for a S-RC script
    • Use Firebug to give you the XPath
  • Designing for Selenium
    • Proper use of tables and CSS div tags makes Selenium much easier
  • Support
    • Because this is free, open source software there is no official support channel
    • Mailing lists
    • Wiki
    • Forums
    • Are your main sources of assistence.
    • But don’t forget your peers!