• Save
Selenium bootcamp slides
Upcoming SlideShare
Loading in...5
×
 

Selenium bootcamp slides

on

  • 2,412 views

Selenium Bootcamp Webdriver training slides. Join our training session by signing up at www.seleniumbootcamp.com

Selenium Bootcamp Webdriver training slides. Join our training session by signing up at www.seleniumbootcamp.com

Statistics

Views

Total Views
2,412
Views on SlideShare
914
Embed Views
1,498

Actions

Likes
1
Downloads
0
Comments
0

5 Embeds 1,498

http://seleniumbootcamp.com 1493
http://www.whiteboxtest.com 2
https://www.google.com 1
https://www.google.co.uk 1
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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…
Post Comment
Edit your comment

Selenium bootcamp slides   Selenium bootcamp slides Presentation Transcript

  • www.time2test.co.uk presents Selenium Bootcamp Webdriver Training !1
  • Join us and Book Online ★ Book ★ One your selenium webdriver training with us day - intensive 10 hours - 8am to 6pm ★ Locations: Dublin, Berlin, Dubai, Brussels, New York, Copenhagen, Zurich ★ Learn and Apply - Practical ★ Lunch and Refreshments inclusive ★ Small classes up to 6 delegates www.time2test.co.uk !2 www.seleniumbootcamp.com
  • book online Bootcamp locations Dublin London Berlin Brussels Delhi Vancouver New York www.time2test.co.uk South Africa !3 Dubai www.seleniumbootcamp.com
  • Berlin September 2013 www.time2test.co.uk !4 www.seleniumbootcamp.com
  • Dublin November 2013 www.time2test.co.uk !5 www.seleniumbootcamp.com
  • Dubai January 2014 www.time2test.co.uk !6 www.seleniumbootcamp.com
  • Book today www.time2test.co.uk !7 www.seleniumbootcamp.com
  • Start !8
  • overview • introductions and background • 90% practical training • 10% theory and coffee www.time2test.co.uk !9 www.seleniumbootcamp.com
  • who we are? • Time2test Limited ( UK) based training company • Specialise in training for testers • Training Locations: UK and Europe • Over 15 Courses: Coding for Testers, Webdriver Automation & Mobile Test Automation www.time2test.co.uk !10 www.seleniumbootcamp.com
  • Fast paced course • We have limited time • We can follow up via Skype if necessary • Email us info@time2test.co.uk with questions www.time2test.co.uk !11 www.seleniumbootcamp.com
  • About the trainer “Hi, I am the trainer. This slide is about me and my technology background.” www.time2test.co.uk !12 www.seleniumbootcamp.com
  • Agenda • 7:45 - 8am - Introductions and Coffee • 8am - 10am - Morning session Timings are approximate • Coffee Break 1 - 15 mins • 10am-1pm - Mid Morning session • Lunch Break - 30 mins • 1pm - 3pm - Afternoon session Time to catch the plane • Coffee Break 2 - 15 mins • 3pm - 6pm - Late Afternoon session www.time2test.co.uk !13 www.seleniumbootcamp.com
  • Training Room • Fire Exits • Water • Lavatories • Breaks and lunch • Wifi connection www.time2test.co.uk !14 www.seleniumbootcamp.com
  • what we will cover? • Selenium 2 WebDriver API • Handling Alerts • Using WebDriver to navigate web applications • Working with Cookies • Basic web Element identification using id, name • Synchronisation strategies • Implicit vs Explicit Waits • Explicit waits using ExpectedConditions • Explicit waits using custom expected conditions • Refactoring to Abstraction layers, Page Object Models and Domain Objects • • • Locating web elements using CSS and XPaths Use of Chrome Developer tools and Firebug WebDriver commands to Interrogate WebElements and pages • JUnit annotations to structure test code • HamCrest commands for test assertions • Page Object Modelling Approaches • WebDriver commands for Interaction and Manipulation • Running tests on multiple browsers: Firefox, Google Chrome • Using JavaScript in your tests • Using Remote WebDriver www.time2test.co.uk !15 www.seleniumbootcamp.com
  • Pre-requisites • Java programming knowledge • jUnit knowledge • Eclipse IDE • Setup on your own machine www.time2test.co.uk !16 some experience needed www.seleniumbootcamp.com
  • What do you already know? • Spend 5 minutes on telling us what you already know about Selenium Webdriver and how you have used it. • Or , tell us about your test automation experience www.time2test.co.uk !17 www.seleniumbootcamp.com
  • Style of teaching • Follow the the examples created by the trainer and then try them out on your machine. • Help each other out. www.time2test.co.uk !18 www.seleniumbootcamp.com
  • course objectives • spend 5 mins and note down your objectives and pass them over to the trainer. • We want to meet your expectations. Feel free to add objectives at any time www.time2test.co.uk !19 www.seleniumbootcamp.com
  • Environment Setup !20
  • overview • Eclipse IDE or IntelliJ IDEA • jUnit for test automation framework • Maven for package dependencies • Firefox installed - default preferred browser for Webdriver www.time2test.co.uk !21 www.seleniumbootcamp.com
  • What is Eclipse IDE • If you don’t have previous experience then just follow the trainers’ examples • Development platform with magic www.time2test.co.uk !22 www.seleniumbootcamp.com
  • What is jUnit? • test automation framework to help organise tests with improved reports www.time2test.co.uk !23 www.seleniumbootcamp.com
  • What is Maven? • configuration tool to manage package dependencies and versions without the headache. www.time2test.co.uk !24 www.seleniumbootcamp.com
  • What is Firefox? • where have you been? • webdriver and Firefox show much love www.time2test.co.uk !25 www.seleniumbootcamp.com
  • webdriver API !26
  • overview • walkthrough of the key webdriver api • commands www.time2test.co.uk !27 www.seleniumbootcamp.com
  • API - must know Webdriver - control the browser • Webdriver driver = new FirefoxDriver(); WebElement - work with elements on the page • WebElement myElement = driver.findElement(By.id(“id”)) it’s an interface to a browser www.time2test.co.uk !28 www.seleniumbootcamp.com
  • API - must know • void get(“url”) - open the web page • void quit() - close the browser • List<WebElement> findElements(By by) - find elements (more than one element) www.time2test.co.uk !29 www.seleniumbootcamp.com
  • API - find Elements • There are many different ways to find elements • By.id(“objectId”) • By.linkText(“textUsedInTheLink”) • By.partialLinkText(“partOftextUsedInTheLink”) • By.tagName(“HTMLNodeTag”) • By.className(“cssClassOnObject”) • By.cssSelector(“cssSelectorOfElement”) • By.xpath(“//xpath/To/Element”) • By.name(“elementName”) www.time2test.co.uk We prefer to use cssSelectors !30 www.seleniumbootcamp.com
  • API - operations • void click() - click on an element • void submit() - perform a submit • String getValue() • void sendKeys(“keysToSend”) - input values • void clear() - clear the input field • String getElementName() - • String getAttriubute() - • boolean toogle() - • void Actions() - perform mouse, drag and drops and keyboard operations www.time2test.co.uk !31 www.seleniumbootcamp.com
  • API - windows and frames working with Browser Windows • driver.getWindowHandles() • driver.switchTo().window.(“window_name”) working with frames • driver.switchTo().frame.(“frame_name”) www.time2test.co.uk !32 www.seleniumbootcamp.com
  • commands map • http://www.mindmeister.com/280141421/selenium-2-webdriver-commands • mind map showing a high level view of API www.time2test.co.uk !33 www.seleniumbootcamp.com
  • locating webElements !34
  • overview • use firebug/chrome developer tools to help with locating webElements • cssSelectors • XPATHS • id • name www.time2test.co.uk !35 www.seleniumbootcamp.com
  • xpaths v cssSelectors • Try to use cssSelectors over XPATHS • your automation scripts will run faster • use XPATHs to save time • finding elements on a page is an art! www.time2test.co.uk !36 www.seleniumbootcamp.com
  • xpaths • This notation // for xpaths • follow the trainer’s examples • use a tool to help determine xpaths www.time2test.co.uk !37 www.seleniumbootcamp.com
  • xpaths - firepath • great tool to assist with xpath determination • use with firebug on firefox www.time2test.co.uk !38 www.seleniumbootcamp.com
  • css selectors • reference sheet • http://www.w3schools.com/cssref/ css_selectors.asp • Too much to learn in one day • With time, you will become a master www.time2test.co.uk !39 www.seleniumbootcamp.com
  • css selectors 2 • partial match on attribute values ^= $= *= www.time2test.co.uk input[id^=‘ctrl’] Starting with: For example, if the ID of an element is ctrl_12, this will locate and return elements with ctrl at the beginning of the ID. input[id$='_userName'] Ending with: For example, if the ID for an element is a_1_ userName, this will locate and return elements with _userName at the end of the ID. input[id*='userName'] Containing: For example, if the ID of an element is panel_ login_userName_textfield, this will use the userName part in the middle to match and locate the element. !40 www.seleniumbootcamp.com
  • css selector gadget • chrome tool extension • Search in google for “CSS Selector Tester” ! www.time2test.co.uk !41 www.seleniumbootcamp.com
  • dynamic elements Does the ID of your element dynamically change? <p id="bootcamp_dynamic_1234">This p tag has a dynamic id</p> ! xpath notation to find the p tag on the page "//p[contains(@id,'bootcamp_dynamic_')]" ! cssSelector notation to find the p tag on the page "p[id*='bootcamp_dynamic_']" www.time2test.co.uk !42 www.seleniumbootcamp.com
  • jUnit and Hamcrest !43
  • overview • what is jUnit? • what is Hamcrest? • how do we use it? www.time2test.co.uk !44 www.seleniumbootcamp.com
  • jUnit • @Before • @BeforeClass • @Test • @After • @AfterClass www.time2test.co.uk !45 www.seleniumbootcamp.com
  • jUnit • Pick up the style used in our examples and then apply them www.time2test.co.uk !46 www.seleniumbootcamp.com
  • hamcrest • Hamcrest is a framework for writing matcher objects allowing 'match' rules to be defined declaratively • introduces matchers and is more friendly to read • use instead of the junit assertions • http://edgibbs.com/junit-4-with-hamcrest/ www.time2test.co.uk !47 www.seleniumbootcamp.com
  • hamcrest usage • A good starting place is the assertThat() method that can now almost always be used in place of the traditional assertEquals(). • assertThat() can be found in org.junit.Assert, but it defines using Hamcrest matchers in the signature: static <T> void assertThat(T actual, org.hamcrest.Matcher<T> matcher) www.time2test.co.uk !48 www.seleniumbootcamp.com
  • hamcrest matchers • allOf() • instanceOf() • any() • is() • anyOf() • not() • anything() • notNullValue() • describedAs() • nullValue() • equalTo() • sameInstance() www.time2test.co.uk !49 www.seleniumbootcamp.com
  • test Structure • good style • void setUp() • void tearDown() • all tests should finish with an assertion • element locators should be defined in a separate class - think about constants www.time2test.co.uk !50 www.seleniumbootcamp.com
  • Alerts and Cookies !51
  • overview • how to handle alerts? • how to handle cookies? www.time2test.co.uk !52 www.seleniumbootcamp.com
  • alerts driver.switchTo().alert().accept(); Alert Demo http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm ! www.time2test.co.uk !53 www.seleniumbootcamp.com
  • cookies Set<Cookie> cookies=driver.manage().getCookies(); for(Cookie cookie:cookies) { System.out.println(cookie.getName()+" "+cookie.getValue()); } //To find the number of cookies used by this site System.out.println("Number of cookies in this site "+cookies.size()); www.time2test.co.uk !54 www.seleniumbootcamp.com
  • wait strategies !55
  • overview • Locating elements on a page is already an art. • Locating elements on a page that don’t always appear in a timely manner is also an art. • Implicit vs Explicit Waits • Explicit waits using ExpectedConditions • Explicit waits using custom expected conditions • fluent waits www.time2test.co.uk !56 www.seleniumbootcamp.com
  • Implicit waits ! Just wait for a period to time //Set the Implicit Wait time Out to 10 Seconds driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); www.time2test.co.uk !57 www.seleniumbootcamp.com
  • Explicit waits Wait until a condition is met WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.titleContains("sele nium")); www.time2test.co.uk !58 www.seleniumbootcamp.com
  • Fluent Waits • ! Use the code that is best for your application under test // Waiting 30 seconds for an element to be present on the page, checking // for its presence once every 5 seconds. Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(30, SECONDS) .pollingEvery(5, SECONDS) .ignoring(NoSuchElementException.class); ! WebElement foo = wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { return driver.findElement(By.id("foo")); } }); www.time2test.co.uk !59 www.seleniumbootcamp.com
  • page objects !60
  • overview • what are page objects? • how to use page objects? www.time2test.co.uk !61 www.seleniumbootcamp.com
  • what are page objects? • popular design pattern • object orientated class for a page • interface to the web page • methods for elements • encapsulates features represented by the page www.time2test.co.uk !62 www.seleniumbootcamp.com
  • benefits of page objects? • more readable code • logical grouping • easy to maintain code • tests don’t change if UI changes - just that page object • clean separation between test code and page specific code www.time2test.co.uk !63 www.seleniumbootcamp.com
  • basic example • http://www.whiteboxtest.com/selenium2-WebDriverPage-Object.php www.time2test.co.uk !64 www.seleniumbootcamp.com
  • cross browser and remote !65
  • overview • running your tests on Firefox • running your tests on IE • running your tests on Chrome • running remotely - selenium grid www.time2test.co.uk !66 www.seleniumbootcamp.com
  • RemoteWebDriver • WebDriver driver = new RemoteWebDriver(new URL(“http://server-with-selenium-grid-running: 4444/wd/ hub"), DesiredCapabilities.firefox()); • This example assumes that Selenium Server is running on server-with-selenium-grid-running with the default port of 4444. • You can run Selenium Server on any machine • For example, I run the test code from my Mac OS X computer but I run Selenium Server on a Window XP machine. www.time2test.co.uk !67 www.seleniumbootcamp.com
  • cross browser • different browsers behave differently • perform most testing on Firefox • some subset test execution on different browsers www.time2test.co.uk !68 www.seleniumbootcamp.com
  • ieWebdriver www.time2test.co.uk !69 www.seleniumbootcamp.com
  • chromeWebdriver www.time2test.co.uk !70 www.seleniumbootcamp.com
  • know how !71
  • Troubleshooting • Can’t click or find an element? • Selenium Versions • Firefox browser versions • Downgrade or upgrade using Maven to manage the versions. www.time2test.co.uk !72 www.seleniumbootcamp.com
  • Simple Google Search Test www.time2test.co.uk !73 www.seleniumbootcamp.com
  • web table data www.time2test.co.uk !74 www.seleniumbootcamp.com
  • dropdown list • Select object and use .select notation www.time2test.co.uk !75 www.seleniumbootcamp.com
  • click • Find an element and then .click(); www.time2test.co.uk !76 www.seleniumbootcamp.com
  • generate random data • create a nice random helper class for your random test data needs www.time2test.co.uk !77 www.seleniumbootcamp.com
  • screenshots • take a screenshot when you spot an error or an exception or for validation purposes. • useful to save this artefacts as part of Jenkins CI ( continuous integration) www.time2test.co.uk !78 www.seleniumbootcamp.com
  • get all links on page • Find elements and put traverse through the List www.time2test.co.uk !79 www.seleniumbootcamp.com
  • advanced - out of scope for SB !80
  • testNG • Support for data-driven testing ! • Annotations : • • • • @BeforeMethod • • @AfterClass • • @BeforeClass @AfterMethod @BeforeSuite @AfterSuite @BeforeTest @AfterTest www.time2test.co.uk !81 www.seleniumbootcamp.com
  • data driven testing • Excel spreadsheets or CSV files to seed your tests • TestNG is good with data driven testing www.time2test.co.uk !82 www.seleniumbootcamp.com
  • conclusions !83
  • goals and objectives ! • • • Review your goals. Have we met your expectations? Email us and we will setup a follow up Skype session www.time2test.co.uk !84 www.seleniumbootcamp.com
  • Thank you for attending - Time2test Team !85