streamline selenium testing with page flow navigation

33
Streamline lenium Testing with Page Flow navigation Ted Husted, NimbleUser, Release Engineer @tedhusted Derek Hansen, NimbleUser, Lead Engineer @nimblederek

Upload: salesforce-developers

Post on 29-Nov-2014

655 views

Category:

Technology


9 download

DESCRIPTION

Join us to learn how to significantly reduce the time needed to write and maintain Selenium tests by using page flows to encapsulate the navigational elements in your application. We'll show you how common, multi-page UI actions in Selenium tests can be abstracted into page flows. With a page flow, developers can cut to the chase in a testing scenario, bypassing the setup often needed to navigate to the beginning of your testable action. Leave knowing what you need to add a high value, low maintenance Selenium test suite to your arsenal.

TRANSCRIPT

Page 1: Streamline Selenium Testing with Page Flow Navigation

Streamline lenium Testingwith Page Flow navigation

Ted Husted, NimbleUser, Release Engineer@tedhusted

Derek Hansen, NimbleUser, Lead Engineer@nimblederek

Page 2: Streamline Selenium Testing with Page Flow Navigation

Safe harborSafe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Page 3: Streamline Selenium Testing with Page Flow Navigation

Source code license - BSD2Copyright (c) 2013, NimbleUser

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or

other materials provided with the distribution.

Neither the name of NimbleUser nor the names of its contributors may be used to endorse or promote products derived from this software without

specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,

BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT

SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL

DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

https://bitbucket.org/nimbleams/open-nu-selenium

Page 4: Streamline Selenium Testing with Page Flow Navigation

Ted HustedRelease Engineer, NimbleUser@tedhusted

Page 5: Streamline Selenium Testing with Page Flow Navigation

Derek HansenLead Engineer, NimbleUser@nimblederek

Page 6: Streamline Selenium Testing with Page Flow Navigation

hands up

Page 7: Streamline Selenium Testing with Page Flow Navigation

unit test Apex code?

Page 8: Streamline Selenium Testing with Page Flow Navigation

test Visualforce page workflows?

Page 9: Streamline Selenium Testing with Page Flow Navigation

use other test tools for Visualforce pages?

Page 10: Streamline Selenium Testing with Page Flow Navigation

run Selenium tests?

Page 11: Streamline Selenium Testing with Page Flow Navigation

Selenium in action

(self-running demo)

Page 12: Streamline Selenium Testing with Page Flow Navigation

why automate UI testing?

Page 13: Streamline Selenium Testing with Page Flow Navigation

why not automate UI testing?

Page 14: Streamline Selenium Testing with Page Flow Navigation

why use Selenium?

Page 15: Streamline Selenium Testing with Page Flow Navigation

just do it

Page 16: Streamline Selenium Testing with Page Flow Navigation

public void testNew() throws Exception {

driver.get("http://www.test.com");

driver.findElementBy(How.ID,"loginForm:tbUsername").sendKeys(“J.Doe”);

driver.findElementBy(How.ID,"loginForm:tbPassword").sendKeys(“Sup3rDup3r”).submit();

// ...

}

Page 17: Streamline Selenium Testing with Page Flow Navigation

public void testNew() throws Exception {driver.get("http://www.test.com");driver.findElementBy(How.ID,”loginForm:tbUsername").sendKeys(“jackbenimble");

driver.findElementBy(How.ID,”loginForm:btnLogin").submit();

driver.findElementBy(How.ID,”adminHomeForm:_activitynew").submit();

driver.findElementBy(How.ID,”addEditEventForm:_IDcancel").submit();

driver.findElementBy(How.ID,”adminHomeForm:_activityold").submit();

//...

Page 18: Streamline Selenium Testing with Page Flow Navigation

Page Objects

Page Flows

Page 19: Streamline Selenium Testing with Page Flow Navigation

// You can enter your usernamepublic LoginPage typeUsername(String username) { // No other method enters a username driver.findElement(usernameLocator).sendKeys(username); return this;}

public HomePage loginAs(String username, String password) { typeUsername(username); typePassword(password); return submitLogin();}

Page 20: Streamline Selenium Testing with Page Flow Navigation
Page 21: Streamline Selenium Testing with Page Flow Navigation

Page Objects

Page Flows

Page 22: Streamline Selenium Testing with Page Flow Navigation

public ResultPage searchFor(String text) { driver.findElement("q")

.sendKeys(text) .submit(); return new ResultPage(driver, false);}

public SearchPage(WebDriver driver, Boolean doNav) {this.driver = driver;

if (doNav) this.driver.get("http://google.com/");}

}

Page 23: Streamline Selenium Testing with Page Flow Navigation

public SearchPage() {@FindBy(how = How.NAME, using = "q")private WebElement searchBox;

public void searchFor(String text) { searchBox.sendKeys(text).submit();}

public SearchPage(WebDriver driver) {driver.get(Where.SEARCH_PAGE);PageFactory.initElements(driver, this);

}}

Page 24: Streamline Selenium Testing with Page Flow Navigation

WebElementvoid clear() void click()WebElement findElement(By by)List findElements(By by)String getAttribute(String name)String getCssValues()Point getLocation()Dimension getSize()String getTagName()String getText();boolean isEnabled()boolean isSelected()void sendKeys(CharSequence keysToSend)void submit()

Page 25: Streamline Selenium Testing with Page Flow Navigation

(show and tell)

Page 26: Streamline Selenium Testing with Page Flow Navigation
Page 27: Streamline Selenium Testing with Page Flow Navigation

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>ams-pkg-test</groupId> <artifactId>ams-pkg-test</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>ams-pkg-test</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies>

<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.35.0</version></dependency><dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope></dependency>

</dependencies></project>

Page 28: Streamline Selenium Testing with Page Flow Navigation

Maven plays well with others

Page 30: Streamline Selenium Testing with Page Flow Navigation

Ted Husted

Release Engineer@tedhusted

Derek Hansen

Lead Engineer,@nimblederek

Page 31: Streamline Selenium Testing with Page Flow Navigation

All about NimbleUser

Nimble AMS is an enterprise Association Management System built by NimbleUser on Force.com. Nimble AMS revolutionizes the traditional AMS model with Chatter, Sites, Apps, Mobile, Social, and more.

Page 32: Streamline Selenium Testing with Page Flow Navigation
Page 33: Streamline Selenium Testing with Page Flow Navigation

2004 - 2006 - 2008 - 2011 - 2014