SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Getting up and running with
Selenium for Automated Web
Testing

Emma Armstrong
Website: www.taooftesting.co.uk

@EmmaATester
Continuous Delivery
Automate and improve software delivery process

Rapidly push out enhancements
to customers
Quick and reliable release cycles
Automated testing

Image from http://en.wikipedia.org/wiki/Postman_Pat
Where to start?
Selenium
• Works with most browsers and is multi platform (c#,
Java, Ruby)
• WebDriver /IDE
• Nuget packages
• Selenium.Support
• Selenium.WebDriver

• Grid capabilities
• Hub and clients
• Simple jar file install commands
Selenium WebDriver
• Add Selenium to your project
• Add Selenium to your class
• Using OpenQA.Selenium;
• Using OpenQA.Selenium.Firefox;

• Create an instance of the WebDriver
• IWebDriver driver = new FirefoxDriver();

• Interact with that driver
• Go to a web page
• Driver. Navigate().GoToUrl(“http://localhost:82”);

• Find an element on the page
• Driver. FindElement(By.Id("Username"))
NUnit
• Add NUnit to your project
• Add NUnit to your class
• Using Nunit.framework;

• Attributes
•
•
•
•

[TestFixture] – indicates the class contains test code
[Test] – indicates that it is a test method
[TestCase]
[TestFixtureSetup] – performed once prior to the tests in that test
fixture being run to initialise
• [TestFixtureTearDown] - performed once after the tests in that test
have run to clean up
Test classes must be public and have a default constructor

• Assert class
• Defines a set of methods you can use to check the post condition
Eating your own dog food
Demo
PageObject Model
• Create a class for each page in your application
• Extract common elements and web elements to a Base
class that the pages can inherit
• Create your base class
• Add selenium support
• Using OpenQA.Selenium.Support.PageObjects;

• Define the elements on the page
• [FindsBy(How = How.Id, Using = "footer_version")] private IWebElement
version;

• Initialise the elements on the page
• PageFactory.InitElements(driver, this);
Nunit test
Example c# nunit test
using System;
using NUnit.Framework;
using RedGate.Deploy.WebAppTests.Pages;
namespace RedGate.Deploy.SmokeTests
{
[TestFixture]
public class VersionTest : SmokeTestBase
{
[Test]
public void LoginPageShowsCurrentVersion()
{
Version expectedVersion = GetType().Assembly.GetName().Version;
LoginPage loginPage = LoginPage.Load(Driver, SmokeTestUrlBase);
Assert.AreEqual("v" + expectedVersion, loginPage.VersionNumber.Trim());
}
Demo
Example Java test
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Import org.openqa.selenium.firefox.firefoxdriver;
Public class javaExample {
public static void main(String[] args) throws Exception {
Webdriver driver = new firefoxdriver();
driver.get("http://localhost:8080");
webelement loginname = driver.findelement(By.id("Username"));
loginname.sendkeys("loginname");
Webelement password = driver.findelement(By.id("Password"));
password.sendkeys("loginname");
Webelement loginbutton = driver.findelement(By.id("loginbutton"));
loginbutton.submit();
driver.quit();
}
}
Selenium Grid Configuration
Install
• java -jar selenium-server-standalone-2.14.0.jar -role hub
• java -jar selenium-server-standalone-2.14.0.jar -role node -hub
http://localhost:4444/grid/register
Usage
• browser browserName=firefox, version=3.6,platform=LINUX
• DesiredCapabilities capability = DesiredCapabilities.firefox();
• webDriver driver = new RemoteWebDriver(new
URL("http://localhost:4444/wd/hub"), capability);
Summary
• Improve confidence in your deployment
• Adding tests is easier than you might think
• Automate gradually
</talk>
Code:
https://github.com/EmmaArmstrong/SeleniumTesting

Emma Armstrong
@EmmaATester

Weitere ähnliche Inhalte

Was ist angesagt?

Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScriptSimon Guest
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2Sebastiano Armeli
 
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
 
Integration Testing With Cucumber How To Test Anything J A O O 2009
Integration Testing With  Cucumber    How To Test Anything    J A O O 2009Integration Testing With  Cucumber    How To Test Anything    J A O O 2009
Integration Testing With Cucumber How To Test Anything J A O O 2009Dr Nic Williams
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascriptkhanhdang1214
 
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
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberKMS Technology
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLhouzman
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular jscodeandyou forums
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object patternMichael Palotas
 
Nightwatch at Tilt
Nightwatch at TiltNightwatch at Tilt
Nightwatch at TiltDave King
 
Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011Adam Christian
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!Jakub Kubrynski
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsSeth McLaughlin
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsSauce Labs
 

Was ist angesagt? (20)

Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScript
 
Protractor
ProtractorProtractor
Protractor
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
 
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
 
Integration Testing With Cucumber How To Test Anything J A O O 2009
Integration Testing With  Cucumber    How To Test Anything    J A O O 2009Integration Testing With  Cucumber    How To Test Anything    J A O O 2009
Integration Testing With Cucumber How To Test Anything J A O O 2009
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascript
 
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)
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Selenium for Jobseekers
Selenium for JobseekersSelenium for Jobseekers
Selenium for Jobseekers
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQL
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular js
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Nightwatch at Tilt
Nightwatch at TiltNightwatch at Tilt
Nightwatch at Tilt
 
Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011
 
Geb with spock
Geb with spockGeb with spock
Geb with spock
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page Objects
 

Ähnlich wie Getting up and running with selenium for automated Code palousa

Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs Selenium Labs
 
Automated testing using Selenium & NUnit
Automated testing using Selenium & NUnitAutomated testing using Selenium & NUnit
Automated testing using Selenium & NUnitAlfred Jett Grandeza
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterBoni García
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriverRajathi-QA
 
Introduction to Selenium and WebDriver
Introduction to Selenium and WebDriverIntroduction to Selenium and WebDriver
Introduction to Selenium and WebDriverTechWell
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionAmr E. Mohamed
 
Integration and Acceptance Testing
Integration and Acceptance TestingIntegration and Acceptance Testing
Integration and Acceptance TestingAlan Hecht
 
Component Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with SeleniumComponent Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with SeleniumRichard Olrichs
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Edureka!
 
Selenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit PathakSelenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit PathakSoftware Testing Board
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.comtestingbot
 

Ähnlich wie Getting up and running with selenium for automated Code palousa (20)

Automated ui-testing
Automated ui-testingAutomated ui-testing
Automated ui-testing
 
Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs
 
Automated testing using Selenium & NUnit
Automated testing using Selenium & NUnitAutomated testing using Selenium & NUnit
Automated testing using Selenium & NUnit
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 
Jbehave selenium
Jbehave seleniumJbehave selenium
Jbehave selenium
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Introduction to Selenium and WebDriver
Introduction to Selenium and WebDriverIntroduction to Selenium and WebDriver
Introduction to Selenium and WebDriver
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Selenium using C# by Yogesh Kumar
Selenium using C# by  Yogesh KumarSelenium using C# by  Yogesh Kumar
Selenium using C# by Yogesh Kumar
 
Integration and Acceptance Testing
Integration and Acceptance TestingIntegration and Acceptance Testing
Integration and Acceptance Testing
 
Automated Testing ADF with Selenium
Automated Testing ADF with SeleniumAutomated Testing ADF with Selenium
Automated Testing ADF with Selenium
 
Component Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with SeleniumComponent Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with Selenium
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Selenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit PathakSelenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit Pathak
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.com
 

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Getting up and running with selenium for automated Code palousa

  • 1. Getting up and running with Selenium for Automated Web Testing Emma Armstrong Website: www.taooftesting.co.uk @EmmaATester
  • 2. Continuous Delivery Automate and improve software delivery process Rapidly push out enhancements to customers Quick and reliable release cycles Automated testing Image from http://en.wikipedia.org/wiki/Postman_Pat
  • 4. Selenium • Works with most browsers and is multi platform (c#, Java, Ruby) • WebDriver /IDE • Nuget packages • Selenium.Support • Selenium.WebDriver • Grid capabilities • Hub and clients • Simple jar file install commands
  • 5. Selenium WebDriver • Add Selenium to your project • Add Selenium to your class • Using OpenQA.Selenium; • Using OpenQA.Selenium.Firefox; • Create an instance of the WebDriver • IWebDriver driver = new FirefoxDriver(); • Interact with that driver • Go to a web page • Driver. Navigate().GoToUrl(“http://localhost:82”); • Find an element on the page • Driver. FindElement(By.Id("Username"))
  • 6. NUnit • Add NUnit to your project • Add NUnit to your class • Using Nunit.framework; • Attributes • • • • [TestFixture] – indicates the class contains test code [Test] – indicates that it is a test method [TestCase] [TestFixtureSetup] – performed once prior to the tests in that test fixture being run to initialise • [TestFixtureTearDown] - performed once after the tests in that test have run to clean up Test classes must be public and have a default constructor • Assert class • Defines a set of methods you can use to check the post condition
  • 7. Eating your own dog food
  • 9. PageObject Model • Create a class for each page in your application • Extract common elements and web elements to a Base class that the pages can inherit • Create your base class • Add selenium support • Using OpenQA.Selenium.Support.PageObjects; • Define the elements on the page • [FindsBy(How = How.Id, Using = "footer_version")] private IWebElement version; • Initialise the elements on the page • PageFactory.InitElements(driver, this);
  • 10. Nunit test Example c# nunit test using System; using NUnit.Framework; using RedGate.Deploy.WebAppTests.Pages; namespace RedGate.Deploy.SmokeTests { [TestFixture] public class VersionTest : SmokeTestBase { [Test] public void LoginPageShowsCurrentVersion() { Version expectedVersion = GetType().Assembly.GetName().Version; LoginPage loginPage = LoginPage.Load(Driver, SmokeTestUrlBase); Assert.AreEqual("v" + expectedVersion, loginPage.VersionNumber.Trim()); }
  • 11. Demo
  • 12. Example Java test import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; Import org.openqa.selenium.firefox.firefoxdriver; Public class javaExample { public static void main(String[] args) throws Exception { Webdriver driver = new firefoxdriver(); driver.get("http://localhost:8080"); webelement loginname = driver.findelement(By.id("Username")); loginname.sendkeys("loginname"); Webelement password = driver.findelement(By.id("Password")); password.sendkeys("loginname"); Webelement loginbutton = driver.findelement(By.id("loginbutton")); loginbutton.submit(); driver.quit(); } }
  • 13. Selenium Grid Configuration Install • java -jar selenium-server-standalone-2.14.0.jar -role hub • java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://localhost:4444/grid/register Usage • browser browserName=firefox, version=3.6,platform=LINUX • DesiredCapabilities capability = DesiredCapabilities.firefox(); • webDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
  • 14. Summary • Improve confidence in your deployment • Adding tests is easier than you might think • Automate gradually

Hinweis der Redaktion

  1. AboutUmbracoEmmaArmstrngTest EngineerRed Gate
  2. java -jar selenium-server-standalone-2.14.0.jar -role hub java -jar selenium-server-standalone-2.14.0.jar -role node  -hub http://localhost:4444/grid/registerbrowser  browserName=firefox, version=3.6,platform=LINUXDesiredCapabilities capability = DesiredCapabilities.firefox();ebDriver driver = new RemoteWebDriver(new URL(&quot;http://localhost:4444/wd/hub&quot;), capability);
  3. java -jar selenium-server-standalone-2.14.0.jar -role hub java -jar selenium-server-standalone-2.14.0.jar -role node  -hub http://localhost:4444/grid/registerbrowser  browserName=firefox, version=3.6,platform=LINUXDesiredCapabilities capability = DesiredCapabilities.firefox();ebDriver driver = new RemoteWebDriver(new URL(&quot;http://localhost:4444/wd/hub&quot;), capability);