SlideShare a Scribd company logo
DevTools to crawl Webpages.
DevTools




09.05.12   @chrschneider   2
DevTools

                                    … Apache … toolset of low level Java components
                                    focused on HTTP and associated protocols.“



  ●   HttpComponents Core
          … is a set of low level HTTP transport components

  ●   HttpComponents Client
          … provides reusable components for client-side ... HTTP connection
          management.

  ●   HttpComponents AsyncClient (DEV)
          … ability to handle a great number of concurrent connections ... more ...
          performance in terms of a raw data throughput.

  ●   Commons HttpClient (Legacy)
         … All users of Commons HttpClient 3.x are strongly encouraged to upgrade to
         HttpClient 4.1.


09.05.12                               @chrschneider                                  3
DevTools

                                                      HttpComponents Client




       Example Components

           ●   Get, Post, Delete, … Request Objects

           ●   Cookie Manager

           ●   SSL

           ●   Content Encoding Aware

           ●   HTTP Authentication (Basic, Digest, ...)




09.05.12                                   @chrschneider                      4
DevTools

                                                      HttpComponents Client Example




           public final static void main(final String[] args) throws Exception
           {

                final HttpClient httpclient = new DefaultHttpClient();
                try
                {
                      final HttpGet httpget = new HttpGet("http://www.google.com/");

                      System.out.println("executing request " + httpget.getURI());

                      // Create a response handler
                      final ResponseHandler<String> responseHandler = new BasicResponseHandler();
                      final String responseBody = httpclient.execute(httpget, responseHandler);
                      System.out.println("----------------------------------------");
                      System.out.println(responseBody);
                      System.out.println("----------------------------------------");

                }
                finally
                {
                      httpclient.getConnectionManager().shutdown();
                }
           }


                                                              http://hc.apache.org/httpcomponents-client-ga/examples.html


09.05.12                                         @chrschneider                                                   5
DevTools

                      HttpComponents Client




               Demo




09.05.12   @chrschneider                      6
DevTools




           … is an asynchronous event-driven network application framework for rapid
           development of maintainable high performance protocol servers & clients.




                          See: http://netty.io/




09.05.12                             @chrschneider                                     7
DevTools

                                      … is a "GUI-Less browser for Java programs"


 Features (extraction):
  ● Support for the HTTP and HTTPS protocols

  ● Support for cookies

  ● Ability to specify whether failing responses from the server should throw exceptions

    or should be returned as pages of the appropriate type (based on content type)
  ● Ability to customize the request headers being sent to the server

  ● Support for HTML responses



   ●   Support for submitting forms
   ●   Support for clicking links
   ●   Support for walking the DOM model of the HTML document
   ●   JavaScript support




09.05.12                             @chrschneider                                 8
DevTools

                                                  … is a "GUI-Less browser for Java programs"



      @Test
      public void homePage() throws Exception
      {
            final WebClient webClient = new WebClient();
            final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net");

           System.out.println(page.getTitleText());

           assertEquals("Welcome to HtmlUnit", page.getTitleText());

           final String pageAsXml = page.asXml();
           assertTrue(pageAsXml.contains("<body class="composite">"));

           final String pageAsText = page.asText();
           assertTrue(pageAsText.contains("Support for the HTTP and HTTPS protocols"));

           webClient.closeAllWindows();
      }




                                                                               http://htmlunit.sourceforge.net/gettingStarted.html


09.05.12                                        @chrschneider                                                          9
DevTools

                                                                 … is a "GUI-Less browser for Java programs"




           @Test
           public void   getElements() throws Exception
           {
                 final   WebClient webClient = new WebClient();
                 final   HtmlPage page = webClient.getPage("http://some_url");
                 final   HtmlDivision div = page.getHtmlElementById("some_div_id");
                 final   HtmlAnchor anchor = page.getAnchorByName("anchor_name");

                 webClient.closeAllWindows();
           }


                                                                                                       Luxus :)



     Note: Also html tables are supported. They wrote easy wrapper classes to walk though them. … Handy!
     http://htmlunit.sourceforge.net/table-howto.html




                                                                                                       http://htmlunit.sourceforge.net/gettingStarted.html


09.05.12                                                      @chrschneider                                                                   10
DevTools

                                             … automates browsers. That's it.




    Selenium-WebDriver supports the following browsers along with the
    operating systems these browsers are compatible with.
      ●    Google Chrome 12.0.712.0+
      ●    Internet Explorer 6, 7, 8, 9 - 32 and 64-bit where applicable
      ●    Firefox 3.0, 3.5, 3.6, 4.0, 5.0, 6, 7
      ●    Opera 11.5+
      ●    HtmlUnit 2.9
      ●    Android – 2.3+ for phones and tablets (devices & emulators)
      ●    iOS 3+ for phones (devices & emulators) and 3.2+ for tablets (devices
           & emulators)


09.05.12                                    @chrschneider                          11
DevTools

                                … automates browsers. That's it.




                           The Selenium Family

           Selenium IDE



                                               Also c#, Phython, Ruby, ...
           Selenium WebDriver

                                                               Also on Windows and Mac



           Selenium Grid



09.05.12                     @chrschneider                                      12
DevTools

                                … automates browsers. That's it.




                           The Selenium Family

                                    … create quick bug reproduction scripts
           Selenium IDE
                                    … create scripts to aid in automation-aided
                                    exploratory testing


           Selenium WebDriver       … create robust, browser-based regression
                                    automation

                                    … scale and distribute scripts across many
                                    environments
           Selenium Grid

                                                                     http://seleniumhq.org/


09.05.12                     @chrschneider                                     13
DevTools

                                            Requirements for Selenium WebDriver with Firefox
                                                             (and HtmlUnit)




              Dependencies                                        Browser Binaries
   <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-java</artifactId>
         <version>2.21.0</version>
   </dependency>

   <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-htmlunit-driver</artifactId>
         <version>2.21.0</version>
   </dependency>

   <dependency>
         <groupId>org.seleniumhq.selenium</groupId>




                                                                           it.
         <artifactId>selenium-firefox-driver</artifactId>




                                                                          's
         <version>2.21.0</version>




                                                                        at
                                                                      Th
   </dependency>




09.05.12                                         @chrschneider                           14
DevTools

                                                               Basic Selenium example




    @Test
    public void testSeleniumWithFirefox() throws InterruptedException
    {
          final WebDriver webDriver = new FirefoxDriver();

           webDriver.get("http://www.majug.de");

           final WebElement veranstaltungenLink = webDriver.findElement(By.linkText("Veranstaltungen"));

           veranstaltungenLink.click();

           // Close the browser
           Thread.sleep(5000);
           webDriver.quit();
    }




09.05.12                                           @chrschneider                                           15
DevTools

                                        Selenium WebDriver Locator Strategies




 It's also possible to call findElements(...) to get a List<> of WebElements.:

               List<WebElement> hits = webDriver.findElements(By.tagName("a"));




09.05.12                                     @chrschneider                        16
DevTools

                                      Selenium WebDriver Interactions




  If you got a webElement, you can...

     ●   webElement.click() it

     ●   webElement.sendKeys(...) to it

     ●   webElement.submit() on it.


  It is also possible to perform “Actions“ like DoubleClick, DragAndDrop, ClickAndHold, …
  with the “Actions“ class.




09.05.12                                  @chrschneider                          17
DevTools

                           Selenium WebDriver




              Demo




09.05.12   @chrschneider                        18
DevTools

                                                        Selenium WebDriver Pitfalls




    Newbie Pitfalls:

    ●   Selenium doesn't wait until the hole site is loaded (Keyword: Implicit wait)
    ●   webElement.xPath(“@// ...“) starts from root of the DOM (use “.//...“ instead)
    ●   Google brings up “Selenium RC“ solutions. This is the old Selenium project.
    ●   A reference to a WebElement will become invalid if the driver “moves“ to
        another page.
    ●   Firefox doesn't run on our CI because it is a headless system (try Xvfb)
    ●   New XPath 2.0 functions (like ends-with(...)) are failing. This is because Selenium
        uses the driver's native Xpath engine. For Firefox this means it is Xpath 1.0 today.




09.05.12                                @chrschneider                                 19
Noch Fragen?
Vielen Dank für Ihre Aufmerksamkeit!

More Related Content

What's hot (17)

PPT
GWT Introduction and Overview - SV Code Camp 09
Fred Sauer
 
PDF
UI-Testing - Selenium? Rich-Clients? Containers? @APEX connect 2018
Tobias Schneck
 
PDF
Java Web Programming [9/9] : Web Application Security
IMC Institute
 
ODP
When dynamic becomes static
Wim Godden
 
PDF
George Thiruvathukal, User Experiences with Plone Content Management
webcontent2007
 
PDF
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
PPT
Introduction tomaven
Manav Prasad
 
PDF
softshake 2014 - Java EE
Alexis Hassler
 
PDF
JEE Programming - 05 JSP
Danairat Thanabodithammachari
 
PDF
Thug: a new low-interaction honeyclient
Angelo Dell'Aera
 
PPTX
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
PDF
Se lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
ekino
 
PPT
Maven basic concept
Ming-Sian Lin
 
PPTX
Testing Ext JS and Sencha Touch
Mats Bryntse
 
PDF
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
Tobias Schneck
 
PDF
In the Brain of Hans Dockter: Gradle
Skills Matter
 
PPTX
Automated php unit testing in drupal 8
Jay Friendly
 
GWT Introduction and Overview - SV Code Camp 09
Fred Sauer
 
UI-Testing - Selenium? Rich-Clients? Containers? @APEX connect 2018
Tobias Schneck
 
Java Web Programming [9/9] : Web Application Security
IMC Institute
 
When dynamic becomes static
Wim Godden
 
George Thiruvathukal, User Experiences with Plone Content Management
webcontent2007
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
Introduction tomaven
Manav Prasad
 
softshake 2014 - Java EE
Alexis Hassler
 
JEE Programming - 05 JSP
Danairat Thanabodithammachari
 
Thug: a new low-interaction honeyclient
Angelo Dell'Aera
 
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
Se lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
ekino
 
Maven basic concept
Ming-Sian Lin
 
Testing Ext JS and Sencha Touch
Mats Bryntse
 
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
Tobias Schneck
 
In the Brain of Hans Dockter: Gradle
Skills Matter
 
Automated php unit testing in drupal 8
Jay Friendly
 

Viewers also liked (16)

PPTX
Cr9 ppt
jacktheballer
 
PDF
Medical management of hiv infection
Imran Khan
 
PPTX
Arthritis
sdiaz123
 
PDF
Medical students amnesia
Imran Khan
 
PDF
Work sample
Nayuribe Ch
 
PDF
Eustace_Harewood_security_company_business_plan
edharewood
 
PDF
DMC Event Presentation for 4 26-2012
DullesMetrorailConnectors
 
PPTX
De tapete a chica de ensueño
Anitha Martinez
 
PDF
Webportfolio nayuribe c
Nayuribe Ch
 
PDF
2010 - 2011 Bermuda Salary Trends Report
edharewood
 
PPTX
Value of Enhanced Hotel Security
edharewood
 
PPTX
Marilyn Monroe
Yulia Potiha
 
PPTX
Embedding with Tableau Server
Russell Christopher
 
PPTX
Paxil: New Indication, New Patients to Help
Christian J. O'Brien
 
PPTX
Focus MS: Accessing the Use of a Patient Centric Model when Treating Multiple...
Christian J. O'Brien
 
PPTX
ADKN, Co. Consulting Team Qsymia Strategic Marketing Plan
Christian J. O'Brien
 
Cr9 ppt
jacktheballer
 
Medical management of hiv infection
Imran Khan
 
Arthritis
sdiaz123
 
Medical students amnesia
Imran Khan
 
Work sample
Nayuribe Ch
 
Eustace_Harewood_security_company_business_plan
edharewood
 
DMC Event Presentation for 4 26-2012
DullesMetrorailConnectors
 
De tapete a chica de ensueño
Anitha Martinez
 
Webportfolio nayuribe c
Nayuribe Ch
 
2010 - 2011 Bermuda Salary Trends Report
edharewood
 
Value of Enhanced Hotel Security
edharewood
 
Marilyn Monroe
Yulia Potiha
 
Embedding with Tableau Server
Russell Christopher
 
Paxil: New Indication, New Patients to Help
Christian J. O'Brien
 
Focus MS: Accessing the Use of a Patient Centric Model when Treating Multiple...
Christian J. O'Brien
 
ADKN, Co. Consulting Team Qsymia Strategic Marketing Plan
Christian J. O'Brien
 
Ad

Similar to Innoplexia DevTools to Crawl Webpages (20)

ODP
Knolx session
Knoldus Inc.
 
PPTX
Selenium Automation in Java Using HttpWatch Plug-in
Sandeep Tol
 
PPTX
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
PPTX
Advanced JavaScript
Mahmoud Tolba
 
PPTX
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Agile Testing Alliance
 
PPTX
Selenium 4 - What's coming our way - v1.0.pptx
Hitesh Prajapati
 
PPTX
Selenium.pptx
orbitprojects
 
PPTX
C# Security Testing and Debugging
Rich Helton
 
PDF
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
PDF
Week 05 Web, App and Javascript_Brandon, S.H. Wu
AppUniverz Org
 
ODP
Automated ui testing with selenium. drupal con london 2011
Yuriy Gerasimov
 
PPTX
Modern Web Technologies
Perttu Myry
 
PPT
Developing Java Web Applications
hchen1
 
PDF
Session on Selenium Powertools by Unmesh Gundecha
Agile Testing Alliance
 
PPTX
Selenium WebDriver training
Vijay Krishnan Ramaswamy
 
PDF
Deview 2013 mobile browser internals and trends_20131022
NAVER D2
 
PDF
HTML5 Intoduction for Web Developers
Sascha Corti
 
ODP
eXo Platform SEA - Play Framework Introduction
vstorm83
 
PDF
Zend Framework Quick Start Walkthrough
Bradley Holt
 
PPT
The Theory Of The Dom
kaven yan
 
Knolx session
Knoldus Inc.
 
Selenium Automation in Java Using HttpWatch Plug-in
Sandeep Tol
 
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Advanced JavaScript
Mahmoud Tolba
 
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Agile Testing Alliance
 
Selenium 4 - What's coming our way - v1.0.pptx
Hitesh Prajapati
 
Selenium.pptx
orbitprojects
 
C# Security Testing and Debugging
Rich Helton
 
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
Week 05 Web, App and Javascript_Brandon, S.H. Wu
AppUniverz Org
 
Automated ui testing with selenium. drupal con london 2011
Yuriy Gerasimov
 
Modern Web Technologies
Perttu Myry
 
Developing Java Web Applications
hchen1
 
Session on Selenium Powertools by Unmesh Gundecha
Agile Testing Alliance
 
Selenium WebDriver training
Vijay Krishnan Ramaswamy
 
Deview 2013 mobile browser internals and trends_20131022
NAVER D2
 
HTML5 Intoduction for Web Developers
Sascha Corti
 
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Zend Framework Quick Start Walkthrough
Bradley Holt
 
The Theory Of The Dom
kaven yan
 
Ad

Recently uploaded (20)

PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Python basic programing language for automation
DanialHabibi2
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 

Innoplexia DevTools to Crawl Webpages

  • 1. DevTools to crawl Webpages.
  • 2. DevTools 09.05.12 @chrschneider 2
  • 3. DevTools … Apache … toolset of low level Java components focused on HTTP and associated protocols.“ ● HttpComponents Core … is a set of low level HTTP transport components ● HttpComponents Client … provides reusable components for client-side ... HTTP connection management. ● HttpComponents AsyncClient (DEV) … ability to handle a great number of concurrent connections ... more ... performance in terms of a raw data throughput. ● Commons HttpClient (Legacy) … All users of Commons HttpClient 3.x are strongly encouraged to upgrade to HttpClient 4.1. 09.05.12 @chrschneider 3
  • 4. DevTools HttpComponents Client Example Components ● Get, Post, Delete, … Request Objects ● Cookie Manager ● SSL ● Content Encoding Aware ● HTTP Authentication (Basic, Digest, ...) 09.05.12 @chrschneider 4
  • 5. DevTools HttpComponents Client Example public final static void main(final String[] args) throws Exception { final HttpClient httpclient = new DefaultHttpClient(); try { final HttpGet httpget = new HttpGet("http://www.google.com/"); System.out.println("executing request " + httpget.getURI()); // Create a response handler final ResponseHandler<String> responseHandler = new BasicResponseHandler(); final String responseBody = httpclient.execute(httpget, responseHandler); System.out.println("----------------------------------------"); System.out.println(responseBody); System.out.println("----------------------------------------"); } finally { httpclient.getConnectionManager().shutdown(); } } http://hc.apache.org/httpcomponents-client-ga/examples.html 09.05.12 @chrschneider 5
  • 6. DevTools HttpComponents Client Demo 09.05.12 @chrschneider 6
  • 7. DevTools … is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. See: http://netty.io/ 09.05.12 @chrschneider 7
  • 8. DevTools … is a "GUI-Less browser for Java programs" Features (extraction): ● Support for the HTTP and HTTPS protocols ● Support for cookies ● Ability to specify whether failing responses from the server should throw exceptions or should be returned as pages of the appropriate type (based on content type) ● Ability to customize the request headers being sent to the server ● Support for HTML responses ● Support for submitting forms ● Support for clicking links ● Support for walking the DOM model of the HTML document ● JavaScript support 09.05.12 @chrschneider 8
  • 9. DevTools … is a "GUI-Less browser for Java programs" @Test public void homePage() throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net"); System.out.println(page.getTitleText()); assertEquals("Welcome to HtmlUnit", page.getTitleText()); final String pageAsXml = page.asXml(); assertTrue(pageAsXml.contains("<body class="composite">")); final String pageAsText = page.asText(); assertTrue(pageAsText.contains("Support for the HTTP and HTTPS protocols")); webClient.closeAllWindows(); } http://htmlunit.sourceforge.net/gettingStarted.html 09.05.12 @chrschneider 9
  • 10. DevTools … is a "GUI-Less browser for Java programs" @Test public void getElements() throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage("http://some_url"); final HtmlDivision div = page.getHtmlElementById("some_div_id"); final HtmlAnchor anchor = page.getAnchorByName("anchor_name"); webClient.closeAllWindows(); } Luxus :) Note: Also html tables are supported. They wrote easy wrapper classes to walk though them. … Handy! http://htmlunit.sourceforge.net/table-howto.html http://htmlunit.sourceforge.net/gettingStarted.html 09.05.12 @chrschneider 10
  • 11. DevTools … automates browsers. That's it. Selenium-WebDriver supports the following browsers along with the operating systems these browsers are compatible with. ● Google Chrome 12.0.712.0+ ● Internet Explorer 6, 7, 8, 9 - 32 and 64-bit where applicable ● Firefox 3.0, 3.5, 3.6, 4.0, 5.0, 6, 7 ● Opera 11.5+ ● HtmlUnit 2.9 ● Android – 2.3+ for phones and tablets (devices & emulators) ● iOS 3+ for phones (devices & emulators) and 3.2+ for tablets (devices & emulators) 09.05.12 @chrschneider 11
  • 12. DevTools … automates browsers. That's it. The Selenium Family Selenium IDE Also c#, Phython, Ruby, ... Selenium WebDriver Also on Windows and Mac Selenium Grid 09.05.12 @chrschneider 12
  • 13. DevTools … automates browsers. That's it. The Selenium Family … create quick bug reproduction scripts Selenium IDE … create scripts to aid in automation-aided exploratory testing Selenium WebDriver … create robust, browser-based regression automation … scale and distribute scripts across many environments Selenium Grid http://seleniumhq.org/ 09.05.12 @chrschneider 13
  • 14. DevTools Requirements for Selenium WebDriver with Firefox (and HtmlUnit) Dependencies Browser Binaries <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.21.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-htmlunit-driver</artifactId> <version>2.21.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> it. <artifactId>selenium-firefox-driver</artifactId> 's <version>2.21.0</version> at Th </dependency> 09.05.12 @chrschneider 14
  • 15. DevTools Basic Selenium example @Test public void testSeleniumWithFirefox() throws InterruptedException { final WebDriver webDriver = new FirefoxDriver(); webDriver.get("http://www.majug.de"); final WebElement veranstaltungenLink = webDriver.findElement(By.linkText("Veranstaltungen")); veranstaltungenLink.click(); // Close the browser Thread.sleep(5000); webDriver.quit(); } 09.05.12 @chrschneider 15
  • 16. DevTools Selenium WebDriver Locator Strategies It's also possible to call findElements(...) to get a List<> of WebElements.: List<WebElement> hits = webDriver.findElements(By.tagName("a")); 09.05.12 @chrschneider 16
  • 17. DevTools Selenium WebDriver Interactions If you got a webElement, you can... ● webElement.click() it ● webElement.sendKeys(...) to it ● webElement.submit() on it. It is also possible to perform “Actions“ like DoubleClick, DragAndDrop, ClickAndHold, … with the “Actions“ class. 09.05.12 @chrschneider 17
  • 18. DevTools Selenium WebDriver Demo 09.05.12 @chrschneider 18
  • 19. DevTools Selenium WebDriver Pitfalls Newbie Pitfalls: ● Selenium doesn't wait until the hole site is loaded (Keyword: Implicit wait) ● webElement.xPath(“@// ...“) starts from root of the DOM (use “.//...“ instead) ● Google brings up “Selenium RC“ solutions. This is the old Selenium project. ● A reference to a WebElement will become invalid if the driver “moves“ to another page. ● Firefox doesn't run on our CI because it is a headless system (try Xvfb) ● New XPath 2.0 functions (like ends-with(...)) are failing. This is because Selenium uses the driver's native Xpath engine. For Firefox this means it is Xpath 1.0 today. 09.05.12 @chrschneider 19
  • 20. Noch Fragen? Vielen Dank für Ihre Aufmerksamkeit!