SlideShare a Scribd company logo
1 of 67
Download to read offline
Real World 
Selenium Testing 
Mary Jo Sminkey! 
CF Webtools
About Me 
• 20+ Years in Web Development! 
• ColdFusion Developer since CF 3.0 Release by Allaire! 
• Author of the ColdFusion ecommerce application CFWebstore! 
• Currently working as Lead Developer for a large ecommerce website 
for classic car parts (Classic Industries)! 
• Hobbies include dog training and showing, photography, baking, game 
playing, scrapbooking and origami.
Software Testing Tools 
Capture replay tool:! 
! 
A tool that allows you, with the knowledge of only one infinite loop 
statement, to create an automated script that will run for any required 
period of time without any verification points and allows you to earn many 
overtime hours for running as well as for creating the script. Best suited 
for short-term contactors. Good for cursor moving if you would like to nap 
in front of the monitor. .
Why Selenium? 
• Automates Testing Applications in the Browser! 
! 
• Continuous Integration Testing - Testing all the integrated components of your 
application from server-side code, to all the client side JS that runs the front end.! 
! 
• Will simulate users interacting with the site and find bugs that unit tests can’t! 
• Portable across many browsers and coding platforms! 
• Popular so easy to find help and plugins, etc. ! 
• Easy to get started with but can also handle very advanced and complex testing.
Installing Selenium 
• Includes IDE (Firefox Plugin) and Web Driver (runs tests on Selenium 
Server)! 
• http://docs.seleniumhq.org! 
• We will focus today on building tests to run in the IDE! 
• Easy for newbies to learn, uses simple HTML syntax ! 
• Plugins available that help debug your scripts! 
• Many tools available to convert IDE scripts to run on Web Driver
Some IDE Tips 
• Set your default timeout to something reasonable, based on the slower responding 
pages on your site. ! 
• To run an individual test, use keyboard shortcut “X” ! 
• If your site uses popup windows, be sure to configure FF to allow them for the 
address (or just turn off the setting to block popups)! 
• The “Find” button can be helpful to highlight the target element, but don’t rely on for 
most XPath locators! 
• The speed slider can be useful to debug a fast-running script, but should not be used 
for tests that don’t pass at full speed.! 
• Some Firefox plugins may cause Selenium tests to work incorrectly (like form fillers) 
so you may want to have a separate FF profile specific for your testing.
Useful Plugins 
• Download at http://docs.seleniumhq.org/download/! 
! 
• Favorites ! 
• Save and quick-launch your favorite test suites! ! 
• File Logging! 
• Real time logging at different levels for your tests ! ! 
• Highlight Elements! 
• Highlights target elements on the page as your tests run! ! 
• Power Debugger! 
• Adds the Pause on Fail button ! ! 
• Stored Variables Viewer! 
• View and delete stored variables in the IDE! 
! 
!
User Extensions 
• You can extend the functionality of Selenium IDE via user extensions.! 
• Docs at: http://docs.seleniumhq.org/docs/08_user_extensions.jsp! 
• Also available at the Selenium Downloads page. ! 
• Some useful ones:! 
• Flow Control - GoTo and While Loops! 
! 
!
Developing a Testing Plan 
• What makes money (or provides value) most for the website?! 
• Which pages are visited most often?! 
• Which browsers are used most often? ! 
• What areas have been the most common to experience bugs? ! 
• If other test methods in place (unit testing, etc.) what types of things 
are not tested by these?
Goals For Tests 
• Robust, not brittle! 
• Don’t rely on data that changes ! 
• Should be able to run on multiple environments! 
• Should run at any speed without errors
Creating Selenium Tests 
• Macro Recording Feature! 
• Useful to get started quickly! 
• Often creates very unreliable locators! 
• Manually writing tests in HTML! 
! 
<tr>! 
! <td>Command</td>! 
! <td>Target</td>! 
! <td>Value</td>! 
</tr>
Verifying Text on the Page 
! 
• verifyText(Not)Present/assertText(Not)Present (deprecated)! 
• Checks that the text exists/does not exist on the webpage, with no element 
specified! 
!! 
• verify(Not)Text/assert(Not)Text! 
• Checks that the text given is found/not found in the element specified! 
!! 
• verify(Not)Title/assert(Not)Title! 
• Checks that the page HTML Title tag matches/does not match the text
Verifying Elements on the Page 
! 
• verifyElement(Not)Present/assertElement(Not)Present ! 
• Checks that the element designated can/can not be located on the page! 
! 
• verify(Not)Table/assert(Not)Table! 
• Checks that the given table designated is found/not found on the page! 
! 
• verify(Not)Attribute/assert(Not)Attribute! 
• Checks that the specified attribute of an element matches/does not match the 
pattern
Verifying Form Elements 
• verify(Not)Checked/assert(Not)Checked! 
• Checks if a toggle element (checkbox/radio button) is in a checked/ unchecked 
state! 
! 
• verify(Not)SelectOptions/assert(Not)SelectOptions ! 
• Checks if the array of options for a selectbox matches/does not match a given 
array! 
! 
• verify(Not)Selected/assert(Not)Selected (deprecated)! 
• Checks that the option matching the pattern is selected (or not selected)
Verifying Form Elements, cont. 
• verify(Not)SelectedId(s)/assert(Not)SelectedId(s) ! 
• Checks that the ID(s) of the selected option(s) matches/does not match the value(s)! 
! 
• verify(Not)SelectedIndex(s)/assert(Not)SelectedIndex(s) ! 
• Checks that the index(es) of the selected option(s) matches/does not match the 
value(s) ! 
! 
• verify(Not)SelectedLabel(s)/assert(Not)SelectedLabel(s)! 
• Checks that the label(s) of the selected option(s) match the pattern ! 
! 
• verify(Not)SelectedValue(s)/assert(Not)SelectedValue(s)! 
• Checks that the value(s) of the selected option(s) match the pattern! 
! 
• verify(Not)Editable/assert(Not)Editable! 
Checks if a form element is/is not editable, ie hasn’t been disabled! 
!
Verifying Cookies 
• verify(Not)CookiePresent/assert(Not)CookiePresent! 
• Checks that the designated cookie is found/not found on the client! 
! 
• verify(Not)Cookie)/assert(Not)Cookie! 
• Checks all the cookies on the page ! 
! 
• verify(Not)CookieByName/assert(Not)CookieByName! 
• Checks that the value of the specified cookie matches/does not match the 
pattern ! 
! 
• verify(Not)SelectedValue(s)/assert(Not)SelectedValue(s)! 
• Checks that the value(s) of the selected option(s) match the pattern
Verifying Alerts 
• verify(Not)Alert/assert(Not)Alert! 
• Checks that the last JS alert matches/does not match the text pattern! 
! 
• verify(Not)AlertPresent/assert(Not)AlertPresent! 
• Checks if a JS alert occurred/did not occur ! 
! 
• verify(Not)Prompt/assert(Not)Prompt! 
• Checks that the last JS prompt matches/does not match the text pattern! 
! 
• verify(Not)PromptPresent/assert(Not)PromptPresent! 
• Checks if a JS prompt occurred/did not occur
Let’s Talk Locators! 
• identifier=id: Select the element with the specified @id attribute. If not found, look for a 
match with @name. (default)! 
! 
• id=id: Select the element with the specified @id attribute.! 
! 
• name=name: Select the element with the specified @name attribute.! 
• May be optionally followed by one or more element-filters, e.g. value! 
! 
• dom=javascriptExpression: Find an element by evaluating the JS DOM expression! 
! 
• link=textPattern: Select the link element which contains the text matching the specified 
pattern! 
! 
• css=cssSelector: Select the element using css selectors. ! 
! 
• xpath=xpathExpression: Locate the element using an XPath expression.
Locator Examples 
id=loginBox! 
! 
name=txtBox! 
name=username value=myName! 
! 
dom=document.forms['myForm'].myDropdown! 
dom=document.images[56]! 
dom=function foo() { return document.links[1]; }; foo();! 
! 
link=Homepage
Locator Examples: CSS Selectors 
This Selector: Finds 
css=p first paragraph tag in the document 
css=a first link in the document 
css=a#id3 link with the matching id element 
css=#linkTest :link link inside the element with the id of linkTest 
css=a[name^="foo"] link with a name attribute beginning with ‘foo’ 
css=span#firstChild + span span that follows the span with the id of firstChild 
css=div#childTest :last-child last child element of the childTest div 
css=div#nthTest :nth-child(2n) 2nd child element of the nthTest div 
css=div#linkTest a first link inside the linkTest element 
css=a[class~="class2"] the link that has a class containing the word ‘class2’ 
css=input[type="text"]:disabled first text input element that is disabled 
css=input[type="checkbox"]:checked first checkbox element that is checked 
css=a:contains("foobar") link that contains the text foobar 
css=a[name*="foo"][alt] link with a name attribute that contains foo and has an alt attribute
Locator Examples: XPath Selectors 
This Selector: Finds 
//img[@alt='The image alt text'] image tag with the given alt text 
//table[@id='table1']//tr[4]/td[2] 4th row, second cell of table1 
//a[contains(@href,'#id1')]/@class the class of the link with an href of ‘#id1’ 
//*[text()="right"] the element with internal text of ‘right’ 
//input[@name='name2' and @value='yes'] input field with name of ‘name2’ and value of ‘yes’ 
//input[@type='submit' and @name='send'] submit button with name atribute of ‘send’ 
//input[@type='radio' and @value='1'] radio button with value of 1 
//table[@id=’table1’]/tbody/../td/a[2]@href The link location for the second link in the first table cell 
//*[contains(text(),'Sample Text')]/..//a[2] oLfo tcaabtlees1 the element that has the text "Sample 
//td[contains(text()),’Label’]/following-sibling::td[1]/a LTeoxcat"te, sth tehne gtaobeles cuepll aw litehv tehle f rtoemxt "tLhaebree la" nadnd f ignedsst tthhee 
link in the next table cell over
More on XPath 
• There are a variety of browser plugins for both Firefox and Chrome that will 
help test and create XPath locators.! 
! 
• You can also use Firebug to right-click on an page element in the HTML 
Inspector to create the XPath for it. ! 
! 
• Typically however, these XPaths tend to be way too complex for what we 
want in Selenium (which is typically as simple an XPath as will get the job 
done). ! 
! 
• It behooves the Selenium developer thus to learn to write their own XPath 
locators. ! 
! 
• Tutorial : http://www.zvon.org/xxl/XPathTutorial/General/examples.html
So let’s look at some tests! 
Selenium Source:! 
! 
https://github.com/SeleniumHQ/selenium! 
!! 
Tests located in:! 
! 
/java/server/test/org/openqa/selenium/tests
Selenium Actions 
• open! 
• Opens a specified URL! ! 
• openWindow/selectWindow! 
• Opens a popup window; select the popup Window! ! 
• check/uncheck! 
• Checks/unchecks a toggle button (checkbox/radio) ! ! 
• select! 
• Selects an option from a drop-down using an option locator! ! 
• submit! 
• Submits the specified form!! ! 
• type!! 
• Sets the value of an input field, as if typed into
More Keystroke Actions 
• click/clickAndWait! 
• Click on a link, button, checkbox or radio button (and wait for the next page to load)! ! 
• clickAt/clickAtAndWait! 
• Click on a link, button, checkbox or radio button based on specific coordinates (and wait 
for the next page to load)! ! 
• fireEvent! 
• Simulate triggering an event, along with its corresponding “onevent” handler! ! 
• focus! 
• Move the focus to the specified element! ! 
• keyDown/keyPress/keyUp! 
• Simulates a user pressing and/or releasing a key! ! 
• typeKeys! 
• Simulates keystroke events on the specified element
Tips on Testing Window Actions 
• After running an openWindow action, you will need to run waitForPopup to 
wait for the window (or tab) to open and finishing loading. ! 
! 
• After waitForPopup, if you want to select the window and do further tests on 
it, run the selectWindow action, with the target of name=${windowName}. ! 
! 
• After you finish testing your popup window, use close (no target) and then 
run selectWindow with a target of ‘null’. This will close the popup and then 
return you to the main window.
Tips on Testing Keystrokes 
• Sending keystrokes don’t always trigger the corresponding “onevent” JS 
methods. You can use the “fireEvent” to make sure the onevent gets fired. ! 
! 
• The ‘typeKeys’ is a convenience way of not having to enter keydown/keyUp/ 
keyPress events for each character, however this command often does not have 
a visible effect on the page. You may need to combine it with a ‘type’ command 
to both have the text visible in a form as well as send the keystroke events. ! 
! 
• The ‘type’ command can also be used to set the value of selectboxes, 
checkboxes, etc. To do this, set the value to the value of the option selected, 
versus the visible text.
Selenium Actions: Wait 
• waitForPageToLoad! 
• Use after any action that causes a new page to load. Replaces “andWait” ! 
• waitForPopUp! 
• Waits for a popup window to appear and load up! 
• waitForElement(Not)Present! 
• Wait until a specific element is found/not on the page! 
• waitForElement(Not)Visible! 
• Wait until a specific element is visible/not visible on the page! 
• waitForSelectedID/Index/Label/Value! 
• Wait until a specified option is selected ! 
• waitForText! 
• Wait for specified text on an element ! 
• setTimeout! 
• Specifies the amount of time to wait for an action to complete
Tips On Using Waits 
• These are going to be critical in testing pages utilizing Ajax! 
! 
• When used successfully you should never need to use a “pause” command in your 
tests to get around tests failing for not waiting for Ajax code to complete.! 
! 
• Use the ‘setTimeout” for page loads or “wait” actions that will take longer typically 
than the default timeout. ! 
! 
• Global Ajax handlers can be very helpful for managing how your pages with Ajax 
perform and thus make writing tests a lot simpler. For instance, we disable form 
submits during Ajax calls and display a “loading” animation. Testing that the 
animation is not visible (via waitForNotVisible) is a simple, standard way across our 
tests to ensure that the Ajax action has completed before continuing.
Storing Variables 
• store (deprecated) / storeExpression! 
• Stores the expression in the specified variable! ! 
• storeEval! 
• Stores the result of evaluating the specified Javascript code snippet ! ! 
• storeText! 
• Stores the text inside the element specified! ! 
• storeAttribute! 
• Stores the value of an element attribute! ! 
• storeLocation! 
• Stores the current page URL! ! 
• storeTitle! 
• Stores the HTML Title of the page
Storing Form Data 
• storeSelectedId(s)! 
• Stores the selected Id(s) of the ! specified selectbox! 
• storeSelectedIndex(es)! 
!• Stores the selected index(s) of the specified selectbox! 
• storeSelectedLabel(s)! 
!Stores the selected index(s) of the specified selectbox! 
• storeSelectedValue(s)! 
!Stores the selected value(s) of the specified selectbox! 
• storeSelectOptions! 
!• Stores all options labels in the specified selectbox! 
• storeValue! 
!• Stores the value of an input field! 
• storeChecked! 
• Gets whether a checkbox/radio button element is checked
Storing Alerts, Cookies 
• storeAlert! 
• Stores the message of a JS alert dialog in the specified variable ! 
! 
• storeConfirmation! 
Stores the message of a JS confirmation dialog ! 
! 
• storePrompt! 
Stores the message of a JS question prompt dialog! 
! 
• storeCookieByName! 
• Stores the value of a cookie
More on Stored Variables 
• Two ways to reference your stored variables:! 
•${myVar}! 
• storedVars[‘myVar’]! 
! 
• These are NOT the same. The first makes a copy of your stored var, the 
other is a direct pointer to it. ! 
! 
• You cannot assign anything to ${myVar}.! 
! 
• If you change storedVars[‘myVar’], the corresponding ${myVar} will not be 
updated until this next Selenium command.
Some Sample Stored Variables 
<tr>! 
! <td>storeExpression</td>! 
! <td>Mary Jo Sminkey</td>! 
! <td>fullName</td>! 
</tr>! 
<tr>! 
! <td>assertText</td>! 
! <td>//table[@id='contactDetailTable']//tr[2]//td</td>! 
! <td>${fullname}</td>! 
</tr>! 
<tr>! 
! <td>storeText</td>! 
! <td>css=span.spanProdPrice</td>! 
! <td>partprice</td>! 
</tr>! 
<tr>! 
! <td>storeEval</td>! 
! <td>parseFloat(storedVars[partprice])</td>! 
! <td>totalPrice</td>! 
</tr>
More on Stored Variables - StoreEval 
• storeEval can be used to perform all kinds of inline Javascript code 
during your tests.! 
! 
• While we typically use it for things like string concatenation you can also 
use it for short circuit tests and simple functions. ! 
! 
• If you have a storeEval chunk of code that you use frequently, it may be 
better moved into a user extension.
Sample StoredEval 
<tr>! 
! <td>storeElementPresent</td>! 
! <td>javascript{storedVars['ButtonA_Xpath']} </td>! 
! <td>ButtonA</td>! 
</tr>! 
<tr>! 
! <td>storeElementPresent</td>! 
! <td>javascript{storedVars['ButtonB_Xpath']} </td>! 
! <td>ButtonA</td>! 
</tr>! 
<tr>! 
! <td>storeEval</td>! 
! <td>(storedVars['ButtonA']==true)?storedVars['ButtonA_Xpath'] :! ! 
! ((storedVars['ButtonB']==true)?storedVars['ButtonB_Xpath']:null);</td>! 
! <td>linkToClick</td>! 
</tr>
Handling Alerts & Prompts 
• answerOnNextPrompt! 
• Sets the answer to response with for the next Javascript prompt ! 
! 
• chooseCancelOnNextConfirmation/chooseOkOnNextConfirmation! 
Stores the response to the next Javascript confirmation dialog ! 
! 
• assertAlert/verifyAlert! 
• Use this to consume the alert and remove it from the browser! 
! 
• assertConfirmation/verifyConfirmation! 
• Use this to consume the confirmation dialog and remove it from the browser! 
! 
• assertPrompt/verifyPrompt! 
• Use this to consume the prompt and remove it from the browser
More on Alerts and Other Dialogs 
• The proper sequence of commands is to use the “onNext” command as appropriate 
for the next item, then the action that will generate the dialog, then the command to 
“consume” it. ! 
! 
• Note that in Selenium you typically will not see JS alerts and dialogs in the browser. ! 
! 
• For newer sites, you may want to consider switching to jQuery UI dialogs or other 
modal dialogs that are handled by making page elements visible/not visible. These 
are typically more reliable and easily handled in Selenium tests, and you can see 
what is happening as well while the test is running.! 
! 
• For these dialogs, you typically will be using “waitForElementVisible” and/or 
“waitForText” commands to determine when the dialog is showing and the 
corresponding “Not” version to determine when it’s been removed.
Working with Cookies 
• createCookie! 
• Adds a new cookie, with path and domain of the page under test 
as default! 
! 
• deleteAllVisibleCookies! 
• Deletes all cookies visible to the current page! 
! 
• deleteCookie! 
• Delete a named cookie with the specified name and domain
More About Cookies 
` 
• If you need to delete cookies prior to starting a test, be sure you start with an 
open command so you are on the right URL, delete the cookies, and then 
run another open command to reload the page with the cookies removed.! 
! 
• The cookie commands will work for the current path of the page that is 
loaded. You can set a different path and other parameters such as recurse in 
the value setting for the command. ! 
! 
• Note that Selenium cannot delete cookies that are set with HTTPOnly. 
Typically we use this setting on production sites for additional security 
against XSS attempts, so if you are generally running your tests only on dev 
and/or staging sites, you can programmatically set the HTTPOnly attribute 
for only production sites, allowing Selenium to act on the cookies in other 
environments.
Logging/Debugging Commands 
• echo! 
• Prints the specified message to the log, also helps debug when viewing the list of 
tests! 
! 
• captureEntirePageScreenshot ! 
• Not widely supported but useful for grabbing a screenshot in your tests! 
! 
• highlight! 
• Briefly changes the background of the specified element to yellow. Similar to the 
Highlight Elements plugin! 
! 
• frames! 
• selectFrame, waitForFrameToLoad, ! 
! 
• advanced scripting! 
• addLocationStrategy, addScript, rollup, runScript, waitForCondition
Other Types of Commands 
• mouse events! 
• mouseDown, mouseUp, mouseOut, mouseOver, mouseUp, doubleClick, 
rightClick, etc. ! 
! 
• dragAndDrop events! 
• dragAndDrop, dragAndDropToObject, setMouseSpeed! 
! 
• more keyboard events! 
• altKeyDown/Up, controlKeyDown/Up, metaKeyDown/Up, shiftKeyDown/Up! 
! 
• frames! 
• selectFrame, waitForFrameToLoad, ! 
! 
• advanced scripting! 
• addLocationStrategy, addScript, rollup, runScript, waitForCondition
Creating Test Suites 
<html>! 
<head>! 
<title>Test Suite</title>! 
</head>! 
<body>! 
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium">! 
<tbody>! 
! <tr><td><b>Test Suite</b></td></tr>! 
! <tr><td><a href="testLogin.html">Test Login</a></td></tr>! 
! <tr><td><a href="testShopping.html">Test Shopping</a></td></tr>! 
! <tr><td><a href="testCheckout.html">Test Checkout</a></td></tr>! 
</tbody>! 
</table>! 
</body>! 
</html>
Let’s Look at a Real Site 
Classic Industries ! 
! 
• Large ecommerce site with 300,000+ product inventory! 
! 
• Heavy use of jQuery and Ajax! 
! 
• Active development in process so frequent updates to production! 
! 
• Some critical areas include product search, user functions and shopping cart/checkout 
processes
Some Challenges 
• Search results always changing due to inventory/stock changing! 
! 
• Different messages, checkout process based on type of product(s) 
ordered! 
! 
• Creating user accounts rely on unique email addresses! 
! 
• Multiple server environments to test on, some using SSL ! 
! 
• Wholesale site that requires users to be logged in to shop! 
! 
• Dev/staging environments already handle some common issues like 
test orders, PayPal sandbox usage, etc.
Handling Dynamic Site Data 
• Our solution here was to create a page for adding “test products” to use! 
! 
• This page runs stored procedures that are only available on development 
and staging servers. ! 
! 
• The test products are created with specific attributes to make them easy to 
locate in searches. ! 
! 
• The form allows for creating all the different types of products that we will 
need to test for. ! 
! 
• We then store the created product numbers that are output by the test data 
creation form to use in our tests.
Demo of Test Data Creation Form
Demo of Test Data Creation Form, cont.
Generating Unique Users 
• We wanted to create users with a real email address in order to verify email sent by 
various site actions.! 
! 
• The site normally does not remove users once added, this is a function handled 
outside the website, but an option might be to add a Delete User function that would 
run after the tests complete. ! 
! 
• Instead we decided to rely on a trick involving gmail accounts. ! 
! 
• A gmail address can be modified with a plus sign (+) and random string of characters, 
and will email to the same base account address. ! 
! 
• So for instance, I can use my email account “mjsminkey@gmail.com” and add a 
random string of characters and use that for a unique email address on the website
Sample Code for Unique Email Account 
<tr>! 
! <td>store</td>! 
! <td>mjsminkey</td>! 
! <td>gMailAccount</td>! 
</tr>! 
<tr>! 
! <td>storeEval</td>! 
! <td>Math.random().toString(36).slice(5)</td>! 
! <td>emailString</td>! 
</tr>! 
<tr>! 
! <td>storeEval</td>! 
! <td>storedVars['gMailAccount'] + "+" + storedVars['emailString'] + "@gmail.com"</td>! 
! <td>email</td>! 
</tr>
Running Test Suites on Different Servers 
• Both the IDE and the tests themselves allow for a baseURL! 
! 
• However, it can be tedious to have to change these anytime you want to run on a 
different URL! 
! 
• Instead, we create a “setEnvironment” file for each server that creates stored 
variables for our base URL, SSL URL, any other settings unique to that environment, 
etc.! 
! 
• All “open” commands or “assertLocation” commands append a path and/or query 
string to the baseURL or sslURL variables.! 
! 
• We then run this setEnvironment as the first test for our suite for that server. ! 
! 
• Can include variable settings for commonly used items in our tests
Sites that Require Logins 
• One approach you can use here is to create a test case that handles the login and 
then run that as the first test case after your set environment test case. ! 
! 
• Alternatively, there is a command available called ‘rollup’ which allows you to include a 
“batch” of commands into your script. ! 
! 
• To use rollup, you will need to include the commands for the batch as a user 
extension. ! 
! 
• Example of rollup:! 
• http://sanjitmohanty.wordpress.com/2012/07/06/using-the-rollup-feature-of-selenium/
Dealing with Whitespace and Locators 
• Most of the assertions for text will treat whitespace as part of the string. ! 
! 
• Where possible, consider updating your HTML to remove unnecessary 
whitespace.! 
! 
• Selenium supports Regex which can be a good option particularly when you are 
trying to store data and there may be whitespace in the element:! 
• parseFloat(storedVars['partprice'].replace(/[^0-9-.]/g, ''))! 
! 
• For assertions, you can use contains() to search anywhere in the text for matches:! 
• //*[contains(text(),'Sample Text')]/..//a[2]! 
! 
• Alternatively you can use “normalize-space” to strip leading and trailing spaces:! 
• //td[normalize-space(text())='My Cell Contents']
More Problem-Solving: CAPTCHA 
• We prefer to use cfformprotect and this is one area it will greatly help you in not 
having to deal with Captchas in your tests!! 
! 
• Most ideal is to set up a test setting for the captcha for your dev/staging 
environment that will return a known value! 
! 
• If you are using a 3rd party captcha system that does not have a method for 
testing, you may want to swap it out for a different one that can be configured as 
above in test environments. ! 
! 
• A last resort might be to use JS prompt for the tester to enter the captcha (use 
storeEval to create a prompt and store the result in a variable that can then be 
used to type in the captcha)
Building a Complete Test: Checkout Test 
1. Set up environment ! 
2. Create stored variables to hold a test user’s contact data, etc. ! 
3. Add some test products to order. ! 
4. Search for test products and add to the shopping cart. ! 
5. Create a user account and login to start checkout! 
6. Enter shipping address and submit form! 
7. Enter billing address and payment and complete order! 
8. Verify order confirmation page
Step 1: Environment Setup
Step 2: Checkout Stored Variables
Step 3: Create Test Products
Step 4: Add Test Products to Cart
Step 5: Create Account and Start Checkout
Step 6a: Check Shipping Form Validations
Step 6b: Shipping State/City Lookup
Step 6c: Complete Shipping Form
Step 7a: Check Billing Form Validations
Step 7b: Submit Billing Form
Step 8: Verify Confirmation Page
Questions?

More Related Content

What's hot

Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend TestingNeil Crosby
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAlan Richardson
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application TestingYnon Perek
 
Nightwatch at Tilt
Nightwatch at TiltNightwatch at Tilt
Nightwatch at TiltDave King
 
Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Andrew Eisenberg
 
UI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected JourneyUI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected JourneyOren Farhi
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Codemotion
 
20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testingVladimir Roudakov
 
Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)Mehdi Khalili
 
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Alan Richardson
 
Test automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinTest automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinOren Rubin
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing AutomationAgileEngine
 
Building testable chrome extensions
Building testable chrome extensionsBuilding testable chrome extensions
Building testable chrome extensionsSeth McLaughlin
 
High Performance JavaScript 2011
High Performance JavaScript 2011High Performance JavaScript 2011
High Performance JavaScript 2011Nicholas Zakas
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCJim Lane
 
Angular UI Testing with Protractor
Angular UI Testing with ProtractorAngular UI Testing with Protractor
Angular UI Testing with ProtractorAndrew Eisenberg
 
Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Mehdi Khalili
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.jsMek Srunyu Stittri
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor🌱 Dale Spoonemore
 

What's hot (20)

Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application Testing
 
Nightwatch at Tilt
Nightwatch at TiltNightwatch at Tilt
Nightwatch at Tilt
 
Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015
 
UI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected JourneyUI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected Journey
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
 
20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing
 
Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)
 
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
 
Test automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinTest automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubin
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
 
Building testable chrome extensions
Building testable chrome extensionsBuilding testable chrome extensions
Building testable chrome extensions
 
High Performance JavaScript 2011
High Performance JavaScript 2011High Performance JavaScript 2011
High Performance JavaScript 2011
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
 
Angular UI Testing with Protractor
Angular UI Testing with ProtractorAngular UI Testing with Protractor
Angular UI Testing with Protractor
 
Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
 

Similar to Real World Selenium Testing

Introduction to Selenium and Ruby
Introduction to Selenium and RubyIntroduction to Selenium and Ruby
Introduction to Selenium and RubyYnon Perek
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Applitools
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Web testing with Selenium
Web testing with SeleniumWeb testing with Selenium
Web testing with SeleniumXBOSoft
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)Dave Haeffner
 
SELECTOR HUB.pptx
SELECTOR HUB.pptxSELECTOR HUB.pptx
SELECTOR HUB.pptxVinayGanji6
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)Sauce Labs
 
Selenium
SeleniumSelenium
Seleniumeduquer
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react formYao Nien Chung
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownMark Rackley
 
Automated testing with Cypress
Automated testing with CypressAutomated testing with Cypress
Automated testing with CypressYong Shean Chong
 
Testing mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkSusannSgorzaly
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Uma Ghotikar
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Ortus Solutions, Corp
 

Similar to Real World Selenium Testing (20)

Real World Selenium
Real World SeleniumReal World Selenium
Real World Selenium
 
Introduction to Selenium and Ruby
Introduction to Selenium and RubyIntroduction to Selenium and Ruby
Introduction to Selenium and Ruby
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Web testing with Selenium
Web testing with SeleniumWeb testing with Selenium
Web testing with Selenium
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
SELECTOR HUB.pptx
SELECTOR HUB.pptxSELECTOR HUB.pptx
SELECTOR HUB.pptx
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
Selenium
SeleniumSelenium
Selenium
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have known
 
Automated testing with Cypress
Automated testing with CypressAutomated testing with Cypress
Automated testing with Cypress
 
Testing mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP framework
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
Selenium Concepts
Selenium ConceptsSelenium Concepts
Selenium Concepts
 

Recently uploaded

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 

Recently uploaded (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 

Real World Selenium Testing

  • 1. Real World Selenium Testing Mary Jo Sminkey! CF Webtools
  • 2. About Me • 20+ Years in Web Development! • ColdFusion Developer since CF 3.0 Release by Allaire! • Author of the ColdFusion ecommerce application CFWebstore! • Currently working as Lead Developer for a large ecommerce website for classic car parts (Classic Industries)! • Hobbies include dog training and showing, photography, baking, game playing, scrapbooking and origami.
  • 3. Software Testing Tools Capture replay tool:! ! A tool that allows you, with the knowledge of only one infinite loop statement, to create an automated script that will run for any required period of time without any verification points and allows you to earn many overtime hours for running as well as for creating the script. Best suited for short-term contactors. Good for cursor moving if you would like to nap in front of the monitor. .
  • 4. Why Selenium? • Automates Testing Applications in the Browser! ! • Continuous Integration Testing - Testing all the integrated components of your application from server-side code, to all the client side JS that runs the front end.! ! • Will simulate users interacting with the site and find bugs that unit tests can’t! • Portable across many browsers and coding platforms! • Popular so easy to find help and plugins, etc. ! • Easy to get started with but can also handle very advanced and complex testing.
  • 5. Installing Selenium • Includes IDE (Firefox Plugin) and Web Driver (runs tests on Selenium Server)! • http://docs.seleniumhq.org! • We will focus today on building tests to run in the IDE! • Easy for newbies to learn, uses simple HTML syntax ! • Plugins available that help debug your scripts! • Many tools available to convert IDE scripts to run on Web Driver
  • 6. Some IDE Tips • Set your default timeout to something reasonable, based on the slower responding pages on your site. ! • To run an individual test, use keyboard shortcut “X” ! • If your site uses popup windows, be sure to configure FF to allow them for the address (or just turn off the setting to block popups)! • The “Find” button can be helpful to highlight the target element, but don’t rely on for most XPath locators! • The speed slider can be useful to debug a fast-running script, but should not be used for tests that don’t pass at full speed.! • Some Firefox plugins may cause Selenium tests to work incorrectly (like form fillers) so you may want to have a separate FF profile specific for your testing.
  • 7. Useful Plugins • Download at http://docs.seleniumhq.org/download/! ! • Favorites ! • Save and quick-launch your favorite test suites! ! • File Logging! • Real time logging at different levels for your tests ! ! • Highlight Elements! • Highlights target elements on the page as your tests run! ! • Power Debugger! • Adds the Pause on Fail button ! ! • Stored Variables Viewer! • View and delete stored variables in the IDE! ! !
  • 8. User Extensions • You can extend the functionality of Selenium IDE via user extensions.! • Docs at: http://docs.seleniumhq.org/docs/08_user_extensions.jsp! • Also available at the Selenium Downloads page. ! • Some useful ones:! • Flow Control - GoTo and While Loops! ! !
  • 9. Developing a Testing Plan • What makes money (or provides value) most for the website?! • Which pages are visited most often?! • Which browsers are used most often? ! • What areas have been the most common to experience bugs? ! • If other test methods in place (unit testing, etc.) what types of things are not tested by these?
  • 10. Goals For Tests • Robust, not brittle! • Don’t rely on data that changes ! • Should be able to run on multiple environments! • Should run at any speed without errors
  • 11. Creating Selenium Tests • Macro Recording Feature! • Useful to get started quickly! • Often creates very unreliable locators! • Manually writing tests in HTML! ! <tr>! ! <td>Command</td>! ! <td>Target</td>! ! <td>Value</td>! </tr>
  • 12. Verifying Text on the Page ! • verifyText(Not)Present/assertText(Not)Present (deprecated)! • Checks that the text exists/does not exist on the webpage, with no element specified! !! • verify(Not)Text/assert(Not)Text! • Checks that the text given is found/not found in the element specified! !! • verify(Not)Title/assert(Not)Title! • Checks that the page HTML Title tag matches/does not match the text
  • 13. Verifying Elements on the Page ! • verifyElement(Not)Present/assertElement(Not)Present ! • Checks that the element designated can/can not be located on the page! ! • verify(Not)Table/assert(Not)Table! • Checks that the given table designated is found/not found on the page! ! • verify(Not)Attribute/assert(Not)Attribute! • Checks that the specified attribute of an element matches/does not match the pattern
  • 14. Verifying Form Elements • verify(Not)Checked/assert(Not)Checked! • Checks if a toggle element (checkbox/radio button) is in a checked/ unchecked state! ! • verify(Not)SelectOptions/assert(Not)SelectOptions ! • Checks if the array of options for a selectbox matches/does not match a given array! ! • verify(Not)Selected/assert(Not)Selected (deprecated)! • Checks that the option matching the pattern is selected (or not selected)
  • 15. Verifying Form Elements, cont. • verify(Not)SelectedId(s)/assert(Not)SelectedId(s) ! • Checks that the ID(s) of the selected option(s) matches/does not match the value(s)! ! • verify(Not)SelectedIndex(s)/assert(Not)SelectedIndex(s) ! • Checks that the index(es) of the selected option(s) matches/does not match the value(s) ! ! • verify(Not)SelectedLabel(s)/assert(Not)SelectedLabel(s)! • Checks that the label(s) of the selected option(s) match the pattern ! ! • verify(Not)SelectedValue(s)/assert(Not)SelectedValue(s)! • Checks that the value(s) of the selected option(s) match the pattern! ! • verify(Not)Editable/assert(Not)Editable! Checks if a form element is/is not editable, ie hasn’t been disabled! !
  • 16. Verifying Cookies • verify(Not)CookiePresent/assert(Not)CookiePresent! • Checks that the designated cookie is found/not found on the client! ! • verify(Not)Cookie)/assert(Not)Cookie! • Checks all the cookies on the page ! ! • verify(Not)CookieByName/assert(Not)CookieByName! • Checks that the value of the specified cookie matches/does not match the pattern ! ! • verify(Not)SelectedValue(s)/assert(Not)SelectedValue(s)! • Checks that the value(s) of the selected option(s) match the pattern
  • 17. Verifying Alerts • verify(Not)Alert/assert(Not)Alert! • Checks that the last JS alert matches/does not match the text pattern! ! • verify(Not)AlertPresent/assert(Not)AlertPresent! • Checks if a JS alert occurred/did not occur ! ! • verify(Not)Prompt/assert(Not)Prompt! • Checks that the last JS prompt matches/does not match the text pattern! ! • verify(Not)PromptPresent/assert(Not)PromptPresent! • Checks if a JS prompt occurred/did not occur
  • 18. Let’s Talk Locators! • identifier=id: Select the element with the specified @id attribute. If not found, look for a match with @name. (default)! ! • id=id: Select the element with the specified @id attribute.! ! • name=name: Select the element with the specified @name attribute.! • May be optionally followed by one or more element-filters, e.g. value! ! • dom=javascriptExpression: Find an element by evaluating the JS DOM expression! ! • link=textPattern: Select the link element which contains the text matching the specified pattern! ! • css=cssSelector: Select the element using css selectors. ! ! • xpath=xpathExpression: Locate the element using an XPath expression.
  • 19. Locator Examples id=loginBox! ! name=txtBox! name=username value=myName! ! dom=document.forms['myForm'].myDropdown! dom=document.images[56]! dom=function foo() { return document.links[1]; }; foo();! ! link=Homepage
  • 20. Locator Examples: CSS Selectors This Selector: Finds css=p first paragraph tag in the document css=a first link in the document css=a#id3 link with the matching id element css=#linkTest :link link inside the element with the id of linkTest css=a[name^="foo"] link with a name attribute beginning with ‘foo’ css=span#firstChild + span span that follows the span with the id of firstChild css=div#childTest :last-child last child element of the childTest div css=div#nthTest :nth-child(2n) 2nd child element of the nthTest div css=div#linkTest a first link inside the linkTest element css=a[class~="class2"] the link that has a class containing the word ‘class2’ css=input[type="text"]:disabled first text input element that is disabled css=input[type="checkbox"]:checked first checkbox element that is checked css=a:contains("foobar") link that contains the text foobar css=a[name*="foo"][alt] link with a name attribute that contains foo and has an alt attribute
  • 21. Locator Examples: XPath Selectors This Selector: Finds //img[@alt='The image alt text'] image tag with the given alt text //table[@id='table1']//tr[4]/td[2] 4th row, second cell of table1 //a[contains(@href,'#id1')]/@class the class of the link with an href of ‘#id1’ //*[text()="right"] the element with internal text of ‘right’ //input[@name='name2' and @value='yes'] input field with name of ‘name2’ and value of ‘yes’ //input[@type='submit' and @name='send'] submit button with name atribute of ‘send’ //input[@type='radio' and @value='1'] radio button with value of 1 //table[@id=’table1’]/tbody/../td/a[2]@href The link location for the second link in the first table cell //*[contains(text(),'Sample Text')]/..//a[2] oLfo tcaabtlees1 the element that has the text "Sample //td[contains(text()),’Label’]/following-sibling::td[1]/a LTeoxcat"te, sth tehne gtaobeles cuepll aw litehv tehle f rtoemxt "tLhaebree la" nadnd f ignedsst tthhee link in the next table cell over
  • 22. More on XPath • There are a variety of browser plugins for both Firefox and Chrome that will help test and create XPath locators.! ! • You can also use Firebug to right-click on an page element in the HTML Inspector to create the XPath for it. ! ! • Typically however, these XPaths tend to be way too complex for what we want in Selenium (which is typically as simple an XPath as will get the job done). ! ! • It behooves the Selenium developer thus to learn to write their own XPath locators. ! ! • Tutorial : http://www.zvon.org/xxl/XPathTutorial/General/examples.html
  • 23. So let’s look at some tests! Selenium Source:! ! https://github.com/SeleniumHQ/selenium! !! Tests located in:! ! /java/server/test/org/openqa/selenium/tests
  • 24. Selenium Actions • open! • Opens a specified URL! ! • openWindow/selectWindow! • Opens a popup window; select the popup Window! ! • check/uncheck! • Checks/unchecks a toggle button (checkbox/radio) ! ! • select! • Selects an option from a drop-down using an option locator! ! • submit! • Submits the specified form!! ! • type!! • Sets the value of an input field, as if typed into
  • 25. More Keystroke Actions • click/clickAndWait! • Click on a link, button, checkbox or radio button (and wait for the next page to load)! ! • clickAt/clickAtAndWait! • Click on a link, button, checkbox or radio button based on specific coordinates (and wait for the next page to load)! ! • fireEvent! • Simulate triggering an event, along with its corresponding “onevent” handler! ! • focus! • Move the focus to the specified element! ! • keyDown/keyPress/keyUp! • Simulates a user pressing and/or releasing a key! ! • typeKeys! • Simulates keystroke events on the specified element
  • 26. Tips on Testing Window Actions • After running an openWindow action, you will need to run waitForPopup to wait for the window (or tab) to open and finishing loading. ! ! • After waitForPopup, if you want to select the window and do further tests on it, run the selectWindow action, with the target of name=${windowName}. ! ! • After you finish testing your popup window, use close (no target) and then run selectWindow with a target of ‘null’. This will close the popup and then return you to the main window.
  • 27. Tips on Testing Keystrokes • Sending keystrokes don’t always trigger the corresponding “onevent” JS methods. You can use the “fireEvent” to make sure the onevent gets fired. ! ! • The ‘typeKeys’ is a convenience way of not having to enter keydown/keyUp/ keyPress events for each character, however this command often does not have a visible effect on the page. You may need to combine it with a ‘type’ command to both have the text visible in a form as well as send the keystroke events. ! ! • The ‘type’ command can also be used to set the value of selectboxes, checkboxes, etc. To do this, set the value to the value of the option selected, versus the visible text.
  • 28. Selenium Actions: Wait • waitForPageToLoad! • Use after any action that causes a new page to load. Replaces “andWait” ! • waitForPopUp! • Waits for a popup window to appear and load up! • waitForElement(Not)Present! • Wait until a specific element is found/not on the page! • waitForElement(Not)Visible! • Wait until a specific element is visible/not visible on the page! • waitForSelectedID/Index/Label/Value! • Wait until a specified option is selected ! • waitForText! • Wait for specified text on an element ! • setTimeout! • Specifies the amount of time to wait for an action to complete
  • 29. Tips On Using Waits • These are going to be critical in testing pages utilizing Ajax! ! • When used successfully you should never need to use a “pause” command in your tests to get around tests failing for not waiting for Ajax code to complete.! ! • Use the ‘setTimeout” for page loads or “wait” actions that will take longer typically than the default timeout. ! ! • Global Ajax handlers can be very helpful for managing how your pages with Ajax perform and thus make writing tests a lot simpler. For instance, we disable form submits during Ajax calls and display a “loading” animation. Testing that the animation is not visible (via waitForNotVisible) is a simple, standard way across our tests to ensure that the Ajax action has completed before continuing.
  • 30. Storing Variables • store (deprecated) / storeExpression! • Stores the expression in the specified variable! ! • storeEval! • Stores the result of evaluating the specified Javascript code snippet ! ! • storeText! • Stores the text inside the element specified! ! • storeAttribute! • Stores the value of an element attribute! ! • storeLocation! • Stores the current page URL! ! • storeTitle! • Stores the HTML Title of the page
  • 31. Storing Form Data • storeSelectedId(s)! • Stores the selected Id(s) of the ! specified selectbox! • storeSelectedIndex(es)! !• Stores the selected index(s) of the specified selectbox! • storeSelectedLabel(s)! !Stores the selected index(s) of the specified selectbox! • storeSelectedValue(s)! !Stores the selected value(s) of the specified selectbox! • storeSelectOptions! !• Stores all options labels in the specified selectbox! • storeValue! !• Stores the value of an input field! • storeChecked! • Gets whether a checkbox/radio button element is checked
  • 32. Storing Alerts, Cookies • storeAlert! • Stores the message of a JS alert dialog in the specified variable ! ! • storeConfirmation! Stores the message of a JS confirmation dialog ! ! • storePrompt! Stores the message of a JS question prompt dialog! ! • storeCookieByName! • Stores the value of a cookie
  • 33. More on Stored Variables • Two ways to reference your stored variables:! •${myVar}! • storedVars[‘myVar’]! ! • These are NOT the same. The first makes a copy of your stored var, the other is a direct pointer to it. ! ! • You cannot assign anything to ${myVar}.! ! • If you change storedVars[‘myVar’], the corresponding ${myVar} will not be updated until this next Selenium command.
  • 34. Some Sample Stored Variables <tr>! ! <td>storeExpression</td>! ! <td>Mary Jo Sminkey</td>! ! <td>fullName</td>! </tr>! <tr>! ! <td>assertText</td>! ! <td>//table[@id='contactDetailTable']//tr[2]//td</td>! ! <td>${fullname}</td>! </tr>! <tr>! ! <td>storeText</td>! ! <td>css=span.spanProdPrice</td>! ! <td>partprice</td>! </tr>! <tr>! ! <td>storeEval</td>! ! <td>parseFloat(storedVars[partprice])</td>! ! <td>totalPrice</td>! </tr>
  • 35. More on Stored Variables - StoreEval • storeEval can be used to perform all kinds of inline Javascript code during your tests.! ! • While we typically use it for things like string concatenation you can also use it for short circuit tests and simple functions. ! ! • If you have a storeEval chunk of code that you use frequently, it may be better moved into a user extension.
  • 36. Sample StoredEval <tr>! ! <td>storeElementPresent</td>! ! <td>javascript{storedVars['ButtonA_Xpath']} </td>! ! <td>ButtonA</td>! </tr>! <tr>! ! <td>storeElementPresent</td>! ! <td>javascript{storedVars['ButtonB_Xpath']} </td>! ! <td>ButtonA</td>! </tr>! <tr>! ! <td>storeEval</td>! ! <td>(storedVars['ButtonA']==true)?storedVars['ButtonA_Xpath'] :! ! ! ((storedVars['ButtonB']==true)?storedVars['ButtonB_Xpath']:null);</td>! ! <td>linkToClick</td>! </tr>
  • 37. Handling Alerts & Prompts • answerOnNextPrompt! • Sets the answer to response with for the next Javascript prompt ! ! • chooseCancelOnNextConfirmation/chooseOkOnNextConfirmation! Stores the response to the next Javascript confirmation dialog ! ! • assertAlert/verifyAlert! • Use this to consume the alert and remove it from the browser! ! • assertConfirmation/verifyConfirmation! • Use this to consume the confirmation dialog and remove it from the browser! ! • assertPrompt/verifyPrompt! • Use this to consume the prompt and remove it from the browser
  • 38. More on Alerts and Other Dialogs • The proper sequence of commands is to use the “onNext” command as appropriate for the next item, then the action that will generate the dialog, then the command to “consume” it. ! ! • Note that in Selenium you typically will not see JS alerts and dialogs in the browser. ! ! • For newer sites, you may want to consider switching to jQuery UI dialogs or other modal dialogs that are handled by making page elements visible/not visible. These are typically more reliable and easily handled in Selenium tests, and you can see what is happening as well while the test is running.! ! • For these dialogs, you typically will be using “waitForElementVisible” and/or “waitForText” commands to determine when the dialog is showing and the corresponding “Not” version to determine when it’s been removed.
  • 39. Working with Cookies • createCookie! • Adds a new cookie, with path and domain of the page under test as default! ! • deleteAllVisibleCookies! • Deletes all cookies visible to the current page! ! • deleteCookie! • Delete a named cookie with the specified name and domain
  • 40. More About Cookies ` • If you need to delete cookies prior to starting a test, be sure you start with an open command so you are on the right URL, delete the cookies, and then run another open command to reload the page with the cookies removed.! ! • The cookie commands will work for the current path of the page that is loaded. You can set a different path and other parameters such as recurse in the value setting for the command. ! ! • Note that Selenium cannot delete cookies that are set with HTTPOnly. Typically we use this setting on production sites for additional security against XSS attempts, so if you are generally running your tests only on dev and/or staging sites, you can programmatically set the HTTPOnly attribute for only production sites, allowing Selenium to act on the cookies in other environments.
  • 41. Logging/Debugging Commands • echo! • Prints the specified message to the log, also helps debug when viewing the list of tests! ! • captureEntirePageScreenshot ! • Not widely supported but useful for grabbing a screenshot in your tests! ! • highlight! • Briefly changes the background of the specified element to yellow. Similar to the Highlight Elements plugin! ! • frames! • selectFrame, waitForFrameToLoad, ! ! • advanced scripting! • addLocationStrategy, addScript, rollup, runScript, waitForCondition
  • 42. Other Types of Commands • mouse events! • mouseDown, mouseUp, mouseOut, mouseOver, mouseUp, doubleClick, rightClick, etc. ! ! • dragAndDrop events! • dragAndDrop, dragAndDropToObject, setMouseSpeed! ! • more keyboard events! • altKeyDown/Up, controlKeyDown/Up, metaKeyDown/Up, shiftKeyDown/Up! ! • frames! • selectFrame, waitForFrameToLoad, ! ! • advanced scripting! • addLocationStrategy, addScript, rollup, runScript, waitForCondition
  • 43. Creating Test Suites <html>! <head>! <title>Test Suite</title>! </head>! <body>! <table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium">! <tbody>! ! <tr><td><b>Test Suite</b></td></tr>! ! <tr><td><a href="testLogin.html">Test Login</a></td></tr>! ! <tr><td><a href="testShopping.html">Test Shopping</a></td></tr>! ! <tr><td><a href="testCheckout.html">Test Checkout</a></td></tr>! </tbody>! </table>! </body>! </html>
  • 44. Let’s Look at a Real Site Classic Industries ! ! • Large ecommerce site with 300,000+ product inventory! ! • Heavy use of jQuery and Ajax! ! • Active development in process so frequent updates to production! ! • Some critical areas include product search, user functions and shopping cart/checkout processes
  • 45. Some Challenges • Search results always changing due to inventory/stock changing! ! • Different messages, checkout process based on type of product(s) ordered! ! • Creating user accounts rely on unique email addresses! ! • Multiple server environments to test on, some using SSL ! ! • Wholesale site that requires users to be logged in to shop! ! • Dev/staging environments already handle some common issues like test orders, PayPal sandbox usage, etc.
  • 46. Handling Dynamic Site Data • Our solution here was to create a page for adding “test products” to use! ! • This page runs stored procedures that are only available on development and staging servers. ! ! • The test products are created with specific attributes to make them easy to locate in searches. ! ! • The form allows for creating all the different types of products that we will need to test for. ! ! • We then store the created product numbers that are output by the test data creation form to use in our tests.
  • 47. Demo of Test Data Creation Form
  • 48. Demo of Test Data Creation Form, cont.
  • 49. Generating Unique Users • We wanted to create users with a real email address in order to verify email sent by various site actions.! ! • The site normally does not remove users once added, this is a function handled outside the website, but an option might be to add a Delete User function that would run after the tests complete. ! ! • Instead we decided to rely on a trick involving gmail accounts. ! ! • A gmail address can be modified with a plus sign (+) and random string of characters, and will email to the same base account address. ! ! • So for instance, I can use my email account “mjsminkey@gmail.com” and add a random string of characters and use that for a unique email address on the website
  • 50. Sample Code for Unique Email Account <tr>! ! <td>store</td>! ! <td>mjsminkey</td>! ! <td>gMailAccount</td>! </tr>! <tr>! ! <td>storeEval</td>! ! <td>Math.random().toString(36).slice(5)</td>! ! <td>emailString</td>! </tr>! <tr>! ! <td>storeEval</td>! ! <td>storedVars['gMailAccount'] + "+" + storedVars['emailString'] + "@gmail.com"</td>! ! <td>email</td>! </tr>
  • 51. Running Test Suites on Different Servers • Both the IDE and the tests themselves allow for a baseURL! ! • However, it can be tedious to have to change these anytime you want to run on a different URL! ! • Instead, we create a “setEnvironment” file for each server that creates stored variables for our base URL, SSL URL, any other settings unique to that environment, etc.! ! • All “open” commands or “assertLocation” commands append a path and/or query string to the baseURL or sslURL variables.! ! • We then run this setEnvironment as the first test for our suite for that server. ! ! • Can include variable settings for commonly used items in our tests
  • 52. Sites that Require Logins • One approach you can use here is to create a test case that handles the login and then run that as the first test case after your set environment test case. ! ! • Alternatively, there is a command available called ‘rollup’ which allows you to include a “batch” of commands into your script. ! ! • To use rollup, you will need to include the commands for the batch as a user extension. ! ! • Example of rollup:! • http://sanjitmohanty.wordpress.com/2012/07/06/using-the-rollup-feature-of-selenium/
  • 53. Dealing with Whitespace and Locators • Most of the assertions for text will treat whitespace as part of the string. ! ! • Where possible, consider updating your HTML to remove unnecessary whitespace.! ! • Selenium supports Regex which can be a good option particularly when you are trying to store data and there may be whitespace in the element:! • parseFloat(storedVars['partprice'].replace(/[^0-9-.]/g, ''))! ! • For assertions, you can use contains() to search anywhere in the text for matches:! • //*[contains(text(),'Sample Text')]/..//a[2]! ! • Alternatively you can use “normalize-space” to strip leading and trailing spaces:! • //td[normalize-space(text())='My Cell Contents']
  • 54. More Problem-Solving: CAPTCHA • We prefer to use cfformprotect and this is one area it will greatly help you in not having to deal with Captchas in your tests!! ! • Most ideal is to set up a test setting for the captcha for your dev/staging environment that will return a known value! ! • If you are using a 3rd party captcha system that does not have a method for testing, you may want to swap it out for a different one that can be configured as above in test environments. ! ! • A last resort might be to use JS prompt for the tester to enter the captcha (use storeEval to create a prompt and store the result in a variable that can then be used to type in the captcha)
  • 55. Building a Complete Test: Checkout Test 1. Set up environment ! 2. Create stored variables to hold a test user’s contact data, etc. ! 3. Add some test products to order. ! 4. Search for test products and add to the shopping cart. ! 5. Create a user account and login to start checkout! 6. Enter shipping address and submit form! 7. Enter billing address and payment and complete order! 8. Verify order confirmation page
  • 57. Step 2: Checkout Stored Variables
  • 58. Step 3: Create Test Products
  • 59. Step 4: Add Test Products to Cart
  • 60. Step 5: Create Account and Start Checkout
  • 61. Step 6a: Check Shipping Form Validations
  • 62. Step 6b: Shipping State/City Lookup
  • 63. Step 6c: Complete Shipping Form
  • 64. Step 7a: Check Billing Form Validations
  • 65. Step 7b: Submit Billing Form
  • 66. Step 8: Verify Confirmation Page