Your SlideShare is downloading. ×
2013 10-10 selenium presentation to ocjug
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2013 10-10 selenium presentation to ocjug


Published on

Published in: Technology

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Testing Web Pages With Selenium Philip H. Schlesinger
  • 2. Introducing PICS PICS simplifies the prequalification process. We help companies to create a safe and sustainable prequalification program for your contractors, vendors and suppliers using a simple, online interface.
  • 3. PICS Technology Stack Cobertura
  • 4. About Me • Since October 2012: Software Development Manager for back-end Java Developers
  • 5. What’s Selenium Open-source browser automation framework
  • 6. Why Not Just Unit Test?
  • 7. Supported Browsers 12.0.712.0+ 2+ 7+ 8+ 3+
  • 8. Supported Operating Systems
  • 9. Supported Programming Languages
  • 10. Supported Testing Frameworks (3rd party)
  • 11. Selenium Methodology
  • 12. Let’s Get Started!
  • 13. Selenium IDE 101 Using Struts2 Archetype In IntelliJ 12 Simple Form Input Verification
  • 14. Welcome Testers Verify Searching For A Name Returns Some Expected Results Not As Easy As It Sounds
  • 15. Welcome Testers Verify The Loan Calculator Returns Valid Calculations For Several Different Scenarios Will Require Additional Coding
  • 16. Another Use For Selenium Automating Interfaces: Filling In Forms With Same Data Over And Over Penetration Testing: Filling In Forms With Different Data Over And Over Hitting URLs With Different Data Over And Over
  • 17. Questions? Philip H. Schlesinger 1.949.936.4508 @PhilSchlesinger
  • 18. We’re Hiring! Our Blog: Currently Open Positions: • Java Architect • Front-End Architect • QA Engineer (SDET) Apply Directly Here (JobVite Link):
  • 19. Addendum How To Replicate The Examples
  • 20. Setting Up The Basic Struts2 Web Form In IntelliJ 12: 1. New Project / Maven 2. Create from archetype / org.apache.struts:struts2archetype-starter 3. Correct problems in struts.xml 4. Configure for Tomcat and Run 5. Site will be at http://localhost:8080/index.action
  • 21. Selenium IDE Firefox Plugin and Server JAR Download from
  • 22. Encoding Hitting The Enter Key In Selenium Command: keyPressAndWait Target: id=q [depends on your form of course] Value: 13 [for enter - any ascii value can go here] Source:
  • 23. Code To Simulate A Mouse Hover In the test, one must hover over the text “MORTGAGES” in order to be able to display its drop-down menu, where the link to the “Mortgage Calculator” is found. Here’s the code to simulate that mouse hover in Selenium. Use it immediately after the line driver.get(baseUrl + "/"); Actions action = new Actions(driver); action.moveToElement(driver.findElement(By.linkT ext("MORTGAGES"))).perform();
  • 24. Capturing A Screenshot In Selenium Code WebDriver driver = new FirefoxDriver(); driver.get(""); File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); // Now you can do whatever you need to do with it, for example copy somewhere FileUtils.copyFile(scrFile, new File("c:tmpscreenshot.png")); Source:
  • 25. Maven Dependency Code <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.35.0</version> </dependency> …will do the basic job. To start the Selenium server as part of running your tests with Maven: <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>2.35.0</version> </dependency> Source:
  • 26. For Verifying A Page’s “Look” At the 2013-10-10 OCJUG presentation, someone asked if Selenium could test if a page actually ended up displaying exactly as expected – or if an image was shifted by a pixel or two. At the time I said I wasn’t aware of a way to test a page’s “look” via Selenium, but then I received a tip: 1. Take a snapshot of the “correct look” of a page via Selenium code 2. Crop at (X,Y) for a certain size A by B 1. 3. This is now your “correct” snapshot Modify the Selenium code to: 1. 2. 3. Take a snapshot of the web page each test Crop at (X,Y) for size A by B Compare the “correct” snapshot that just-taken-and-cropped snapshot with file size, file hashes, via ImageMagick, or some other methodology
  • 27. To Learn More About Creating A Selenium Framework For Your Website Google the following terms: • Data Driven Testing (aka DDT) – Involves data mapping and canonical schema mapping between DB and WebObjects, in this sense, it's also a part of Data Integrity Checking effort • Component Modeling • Domain Specific Language (or Layer) (aka DSL) – Component Model and DSL is a pure OOD (Object Oriented Design) and that's the core engine to give you an action-command type script interface … or just contact me 