SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
WebDriver API Cheat Sheets
● A short set of Summary Cheat Sheets for Hands
On Working With WebDriver
● Contents:
– Basic API commands
– Hamcrest matchers & Junit
– IntelliJ Tips
– CSS & Xpath Selectors
– Contact Details
SeleniumSimplified.com | compendiumdev.co.uk | eviltester.com
Copyright Alan Richardson,
Compendium Developments
@eviltester
Created to support our Selenium
2 WebDriver Training Courses
API Overview
http://www.mindmeister.com/280141421/selenium-2-webdriver-commands
http://www.mindmeister.com/280141421/selenium-2-webdriver-commands
WebDriver Level Basics
WebElement
Interrogation
Basics
http://www.mindmeister.com/280141421/selenium-2-webdriver-commands
http://www.mindmeister.com/280141421/selenium-2-webdriver-commands
WebElement
Manipulation
Synchronisation
HTML, Web
Domain
Basic API
IntelliJ Tips
● Use Code Completion
● ctrl+Q for Documentation of Commands
● ctrl+click to view the method code
● Switch on AutoScroll
● Find Symbol
– Shift + Cntrl + Alt + N
● Find Class
– Cntrl + N
● Find File
– Shift + Ctnrl + N
10
● ExpectedConditions static methods
● Custom ExpectedCondition
Synchronisation WebDriverWait
private ExpectedCondition<WebElement> optionWithValueDisplayed(
final String value) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver webDriver) {
return webDriver.findElement(
By.cssSelector("option[value='" + value + "']") );
}
};
}
new WebDriverWait(driver,10).until(
optionWithValueDisplayed(By.id("combo2"),"Java") );
new WebDriverWait(driver,10).until(
ExpectedConditions.titleIs("HTML Form Elements"));
SlowLoadableCompnent
● Public interface
– get()
● loads and waits for component to be available
extends SlowLoadableComponent<PageObjectClassName>
● Call super constructor in constructor
public PageObjectClassName(WebDriver driver) {
super(new SystemClock(), 10);
this.driver = driver;
}
● Implement load and isLoaded
– isLoaded throws a new Error if not loaded
– I often leave the 'load' part empty if I navigate to the page
● @Test
● @Before, @After (method level)
● @BeforeClass, @AfterClass (static)
Hamcrest Matchers & JUnit
● is
● not
● Number
– greaterThan,
– greaterThanOrEqualTo,
– lessThan,
– lessThanOrEqualTo - test
ordering
● Text
– equalToIgnoringCase
– equalToIgnoringWhiteSpace
– containsString,
– endsWith,
– startsWith
● Collections
– hasEntry,
– hasKey,
– hasValue - test a map contains an
entry, key or value
– hasItem,
– hasItems - test a collection
contains elements
– hasItemInArray - test an array
contains an element
● notNullValue,
● nullValue - test for null
http://code.google.com/p/hamcrest/wiki/Tutorial#A_tour_of_common_matchers
e.g. assertThat(driver.getTitle(), is(not(“bob”));
13
Selectors CSS Selectors
* - any
#id
.class
tag
[attribute]
[attribute="value"]
tag[attribute="value"]
tag[attr1='val1'][attr2='val2']
tag[att1='val1'], orThisTag
= (' or ")
*="anywhere in value"
^="start of value"
$="end of value"
~="spaceSeperatedValue"
Paths
A > B (child)
A B (any descendant)
A + B (A's B sibling)
tag:first-child
XPATH Selectors
// - match anywhere
/ - match from root
//* - any element
//tag
//*[@attribute]
//*[@attribute="value"]
//tag[@attribute="value"]
//tag1/tag2 (child)
//tag1//tag2 (any descendant)
//tag1/../.. (.. to go up)
//*[.='element text']
[@at1="a" and @at2="b"]
and, or, =, !=, <, >, >=, <-
Functions
contains(@a,"alu")
starts-with(@a,"v")
ends-with(@a,"e")
Indexing
//tag[1]
XPath References
● http://www.w3schools.com/xpath/
● http://www.simple-talk.com/dotnet/.net-framework/xpath,-css,-dom-and-selenium-the-rosetta-stone/
CSS References
● http://reference.sitepoint.com/css/selectorref
● http://net.tutsplus.com/tutorials/html-css-techniques/
the-30-css-selectors-you-must-memorize/
● http://www.quirksmode.org/css/contents.html
● http://www.w3schools.com/cssref/css_selectors.asp
14
Blogs and Web Sites
● SeleniumSimplified.com
● EvilTester.com
● Testing Papers and Tools
– CompendiumDev.co.uk
Twitter: @eviltester
Online Training Courses
● Technical Web Testing 101
– Unow.be/at/udemy101
● Intro to Selenium
– Unow.be/at/udemystart
● Selenium 2 WebDriver API
– Unow.be/at/udemyapi
Videos
youtube.com/user/EviltesterVideos
Books
Selenium Simplified
Unow.be/rc/selsimp
Alan Richardson is an Independent Test
Consultant based in the UK. He offers training
and consultancy in Selenium WebDriver,
exploratory and technical web testing.
– uk.linkedin.com/in/eviltester
Contact Alan for training and
consultancy tailored to your needs:
alan@compendiumdev.co.uk

Contenu connexe

Plus de Alan Richardson

Secrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesSecrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesAlan Richardson
 
Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Alan Richardson
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonAlan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsAlan Richardson
 
Technology Based Testing
Technology Based TestingTechnology Based Testing
Technology Based TestingAlan Richardson
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAlan Richardson
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST APIAlan Richardson
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameTechnical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameAlan Richardson
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzAlan Richardson
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to codeAlan Richardson
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With AgilityAlan Richardson
 
Your Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyYour Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyAlan Richardson
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.Alan Richardson
 
What is Agile Testing? A MindMap
What is Agile Testing? A MindMapWhat is Agile Testing? A MindMap
What is Agile Testing? A MindMapAlan Richardson
 
Evil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingEvil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingAlan Richardson
 
The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017Alan Richardson
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?Alan Richardson
 
Effective Software Testing for Modern Software Development
Effective Software Testing for Modern Software DevelopmentEffective Software Testing for Modern Software Development
Effective Software Testing for Modern Software DevelopmentAlan Richardson
 

Plus de Alan Richardson (20)

Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
 
Secrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesSecrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slides
 
Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStrings
 
Technology Based Testing
Technology Based TestingTechnology Based Testing
Technology Based Testing
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil Tester
 
Shift left-testing
Shift left-testingShift left-testing
Shift left-testing
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST API
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameTechnical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" Game
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzz
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to code
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With Agility
 
Your Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyYour Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be Flaky
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.
 
What is Agile Testing? A MindMap
What is Agile Testing? A MindMapWhat is Agile Testing? A MindMap
What is Agile Testing? A MindMap
 
Evil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingEvil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile Testing
 
The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?
 
Effective Software Testing for Modern Software Development
Effective Software Testing for Modern Software DevelopmentEffective Software Testing for Modern Software Development
Effective Software Testing for Modern Software Development
 

Dernier

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
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
 

Dernier (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 

Webdriver cheatsheets Summary Slides

  • 1. WebDriver API Cheat Sheets ● A short set of Summary Cheat Sheets for Hands On Working With WebDriver ● Contents: – Basic API commands – Hamcrest matchers & Junit – IntelliJ Tips – CSS & Xpath Selectors – Contact Details SeleniumSimplified.com | compendiumdev.co.uk | eviltester.com Copyright Alan Richardson, Compendium Developments @eviltester Created to support our Selenium 2 WebDriver Training Courses
  • 9. IntelliJ Tips ● Use Code Completion ● ctrl+Q for Documentation of Commands ● ctrl+click to view the method code ● Switch on AutoScroll ● Find Symbol – Shift + Cntrl + Alt + N ● Find Class – Cntrl + N ● Find File – Shift + Ctnrl + N
  • 10. 10 ● ExpectedConditions static methods ● Custom ExpectedCondition Synchronisation WebDriverWait private ExpectedCondition<WebElement> optionWithValueDisplayed( final String value) { return new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver webDriver) { return webDriver.findElement( By.cssSelector("option[value='" + value + "']") ); } }; } new WebDriverWait(driver,10).until( optionWithValueDisplayed(By.id("combo2"),"Java") ); new WebDriverWait(driver,10).until( ExpectedConditions.titleIs("HTML Form Elements"));
  • 11. SlowLoadableCompnent ● Public interface – get() ● loads and waits for component to be available extends SlowLoadableComponent<PageObjectClassName> ● Call super constructor in constructor public PageObjectClassName(WebDriver driver) { super(new SystemClock(), 10); this.driver = driver; } ● Implement load and isLoaded – isLoaded throws a new Error if not loaded – I often leave the 'load' part empty if I navigate to the page
  • 12. ● @Test ● @Before, @After (method level) ● @BeforeClass, @AfterClass (static) Hamcrest Matchers & JUnit ● is ● not ● Number – greaterThan, – greaterThanOrEqualTo, – lessThan, – lessThanOrEqualTo - test ordering ● Text – equalToIgnoringCase – equalToIgnoringWhiteSpace – containsString, – endsWith, – startsWith ● Collections – hasEntry, – hasKey, – hasValue - test a map contains an entry, key or value – hasItem, – hasItems - test a collection contains elements – hasItemInArray - test an array contains an element ● notNullValue, ● nullValue - test for null http://code.google.com/p/hamcrest/wiki/Tutorial#A_tour_of_common_matchers e.g. assertThat(driver.getTitle(), is(not(“bob”));
  • 13. 13 Selectors CSS Selectors * - any #id .class tag [attribute] [attribute="value"] tag[attribute="value"] tag[attr1='val1'][attr2='val2'] tag[att1='val1'], orThisTag = (' or ") *="anywhere in value" ^="start of value" $="end of value" ~="spaceSeperatedValue" Paths A > B (child) A B (any descendant) A + B (A's B sibling) tag:first-child XPATH Selectors // - match anywhere / - match from root //* - any element //tag //*[@attribute] //*[@attribute="value"] //tag[@attribute="value"] //tag1/tag2 (child) //tag1//tag2 (any descendant) //tag1/../.. (.. to go up) //*[.='element text'] [@at1="a" and @at2="b"] and, or, =, !=, <, >, >=, <- Functions contains(@a,"alu") starts-with(@a,"v") ends-with(@a,"e") Indexing //tag[1] XPath References ● http://www.w3schools.com/xpath/ ● http://www.simple-talk.com/dotnet/.net-framework/xpath,-css,-dom-and-selenium-the-rosetta-stone/ CSS References ● http://reference.sitepoint.com/css/selectorref ● http://net.tutsplus.com/tutorials/html-css-techniques/ the-30-css-selectors-you-must-memorize/ ● http://www.quirksmode.org/css/contents.html ● http://www.w3schools.com/cssref/css_selectors.asp
  • 14. 14 Blogs and Web Sites ● SeleniumSimplified.com ● EvilTester.com ● Testing Papers and Tools – CompendiumDev.co.uk Twitter: @eviltester Online Training Courses ● Technical Web Testing 101 – Unow.be/at/udemy101 ● Intro to Selenium – Unow.be/at/udemystart ● Selenium 2 WebDriver API – Unow.be/at/udemyapi Videos youtube.com/user/EviltesterVideos Books Selenium Simplified Unow.be/rc/selsimp Alan Richardson is an Independent Test Consultant based in the UK. He offers training and consultancy in Selenium WebDriver, exploratory and technical web testing. – uk.linkedin.com/in/eviltester Contact Alan for training and consultancy tailored to your needs: alan@compendiumdev.co.uk