Selenium

Selenium
Outline
Uniqueness of web app testing
Heterogonous system
Dynamic pages
Load
Security
Selenium WebDriver
Course project 4
Web application architecture
Heterogeneous system
Front end
 Browser: IE, Firefox, Chrome, Safari…
Server side
 Application Server
 Database Server
 File System
 ……
Heterogeneous system
Front end
HTML, JavaScript, Adobe Flash……
HTML
JavaScript
Page in Browser
Source behind
Heterogeneous system
Should test all involved parts
Everything can go wrong…
However, only front end is accessible for tests
Can not directly test the Server code and SQL
Have to drive the execution and test
 Frontend
 HTML: Malformed HTML page? (demo)
 JavaScript: Runtime Errors? (demo)
 Server script
 PHP, Java…: Runtime Errors? (demo)
 SQL: Malformed SQL query string? (demo)
Test from the front end
Good things
Hide the complexity of the backend
Uniformed interface
Can put a robot in the front end and automate the tests
Bad things
The front end is not trustable
 Crafted malicious requests
Good things of testing from the
front end
 Automated web app testing
 Compare to commend-line program testing…
 Sensitive to input values (the same)
 GUI testing: event driven (the difference)
 “Button A” then “Button B”  OK
 “Button B” then “Button A”  FAIL
 The robot should be able to
 Provide input values
 Simulate user actions
 Selenium
 A tool set automates web app testing across platforms
 Can simulate user interactions in browser
 Two components
 Selenium IDE
 Selenium WebDriver (aka. Selenium 2)
Selenium IDE
Firefox extension
Easy record and replay
Debug and set breakpoints
Save tests in HTML,
WebDriver and other
formats.
Selenium IDE test cases
Selenium saves all information in an HTML table format
Each record consists of:
Command – tells Selenium what to do (e.g. “open”, “type”, “click”,
“verifyText”)
Target – tells Selenium which HTML element a command refers to
(e.g. textbox, header, table)
Value – used for any command that might need a value of some
kind (e.g. type something into a textbox)
How to record/replay with
Selenium IDE
1. Start recording in Selenium IDE
2. Execute scenario on running web application
3. Stop recording in Selenium IDE
4. Verify / Add assertions
5. Replay the test.
Selenium IDE Demo……
Bad things of testing from the front end
The front end is not trustable
Front end code can be accessed to anybody
They can infer the input parameters
 Crafted requests!
Demo
Front end limits the length of the input values
Front end limits the content of the input values
Front end limits the combination of the input values
Uniqueness 2: Dynamic pages
Client page is dynamic
 It can change itself in the runtime
 HTML can be modified by JavaScript
 JavaScript can modify itself
 Demo
Server script is dynamic
 Client pages are constructed in the runtime
 A same server script can produce completely different client
pages
 Demo
 SchoolMate
Uniqueness 3: Performance
Performance is crucial to the success of a web app
 Recall the experience to register for a class in the first days of
the semester…
 Are the servers powerful enough?
Performance testing evaluates system performance under
normal and heavy usage
 Load testing
 For expected concurrent number of users
 Stress testing
 To understand the upper limits of capacity
Performance testing can be automated
Uniqueness 4: Security
Web app usually deals with sensitive info, e.g.
Credit card number
SSN
Billing / Shipping address
Security is the biggest concern
Security testing should simulate possible attacks
Uniqueness 4: Security
SQL Injection
The untrusted input is used to construct dynamic SQL
queries.
E.g, update my own password
$str = "UPDATE users SET password = ” “ . $_POST['newPass’] .
“” WHERE username =”“ . $_POST['username'] . “””;
mysql_query( $str );
$_POST['newPass’] = pass, $_POST['username'] = me
Query String: UPDATE users SET password = “pass” WHERE username =“me”
$_POST['newPass’] = pass, $_POST['username'] = “ OR 1=1 --
Query String: UPDATE users SET password = “pass” WHERE username =“” OR 1=1 --”
Normal Case
Attack
PHP ScriptPHP Script
Uniqueness 4: Security
Cross Site Scripting (XSS)
The untrusted input is used to construct dynamic
HTML pages.
The malicious JS injected executes in victim’s browser
The malicious JS can steal sensitive info
Demo
Solution: Never trust user inputs
Design test cases to simulate attacks
Outline
Uniqueness of web app testing
Heterogonous system
Dynamic pages
Load
Security
Selenium WebDriver
Course project 4
Limitation of Selenium IDE
No multiple browsers support
It runs only in Mozilla Firefox.
No manual scripts
E.g. conditions and Loops for Data Driven Testing
Fancy test cases  Selenium WebDriver
Selenium WebDriver (Selenium 2)
 Selenium-WebDriver
 A piece of program
 Control the browser by programming
 More flexible and powerful
 Selenium-WebDriver supports multiple browsers in multiple
platforms
 Google Chrome 12.0.712.0+
 Internet Explorer 6+
 Firefox 3.0+
 Opera 11.5+
 Android – 2.3+ for phones and tablets
 iOS 3+ for phones
 iOS 3.2+ for tablets
Selenium WebDriver
WebDriver is designed to providing a simpler and
uniformed programming interface
Same WebDriver script runs for different platforms
Support multiple programming language:
Java, C#, Python, Ruby, PHP, Perl…
It’s efficient
WebDriver leverages each browser’s native support for
automation.
What Selenium can do
A solution for the automated testing
Simulate user actions
Functional testing
 Create regression tests to verify functionality and user
acceptance.
Browser compatibility testing
 The same script can run on any Selenium platform
Load testing
Stress testing
How to use Selenium WebDriver
(1) Go to a page
(2) Locate an element
(3) Do something with that element
......
(i) Locate an element
(i+1) Do something with that element
(i+2) Verify / Assert the result
Demo: Verify page title
public static void main( String[] args )
{
// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();
// (1) Go to a page
driver.get("http://www.google.com");
// (2) Locate an element
WebElement element = driver.findElement(By.name("q"));
// (3-1) Enter something to search for
element.sendKeys("Purdue Univeristy");
// (3-2) Now submit the form. WebDriver will find the form for us from the element
element.submit();
// (3-3) Wait up to 10 seconds for a condition
WebDriverWait waiting = new WebDriverWait(driver, 10);
waiting.until( ExpectedConditions.presenceOfElementLocated( By.id("pnnext") ) );
// (4) Check the title of the page
if( driver.getTitle().equals("purdue univeristy - Google Search") )
System.out.println("PASS");
else
System.err.println("FAIL");
//Close the browser
driver.quit();
}
How to locate an element
 By id
 HTML: <div id="coolestWidgetEvah">...</div>
 WebDriver:
 driver.findElement( By.id("coolestWidgetEvah") );
 By name
 HTML: <input name="cheese" type="text"/>
 WebDriver: driver.findElement( By.name("cheese") );
 By Xpath
 HTML
 <html>
 <input type="text" name="example" />
 <input type="text" name="other" />
 </html>
 WebDriver: driver.findElements( By.xpath("//input") );
 There are plug-ins for firefox/chrome to automatically display the Xpath

Timeissue
There are delays between submitting a request and
receiving the response
We can wait until the response page is loaded
Robot doesn’t know!
In WebDriver, sometimes it doesn’t work if
 Submit a request
 Verify the response immediately
Solution:
 Simulate the wait. Wait until some HTML object appears
 Demo
Outline
What to test for a web application
Test web app with selenium
What’s Selenium?
Why Selenium?
How to use Selenium
Course project 4
Course Project 4
Test a functionality without the source
The subject web application
“Add New Class” in “SchoolMate”
Course Project 4
Part 1: overview
Design test cases against the requirement
 The tests should consider
 all possible cases
 equivalence class partitioning
Implement Selenium WebDriver Script for “Add new
class”
Your testYour test
casescases
Your WebDriverYour WebDriver
test templatetest template
inputinput outputoutput
TestTest
resultsresults
Part 1: requirement analysis
Requirement for the “add” function
After clicking the “Add class” button…
[R-6] The class record added is successfully shown in
the table.
[R-7] The values are exactly the same as those were
entered or selected.
Part 1: Implement WebDriver
Script
 In WebDriver script, Simulate the user action
Navigate to the subject page
Enter values into textboxs based on input values
Select options based on input values
Click the “add class” button
Check the result against the requirements
Run all your test cases and report the results.
Course Project 4
Part 2: Pair wise testing
Use an existing pair wise testing tool fire-eye
Largely you may reuse the WebDriver template in Part 1
Your testYour test
casescases
Your WebDriverYour WebDriver
test templatetest template
inputinput outputoutput
TestTest
resultresult
Test casesTest cases
generatedgenerated
ConvertConvert
1 de 31

Recomendados

Selenium testing - Handle Elements in WebDriver por
Selenium testing - Handle Elements in WebDriver Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver Vibrant Technologies & Computers
262 vistas38 diapositivas
Selenium web driver por
Selenium web driverSelenium web driver
Selenium web driverRoman Savitskiy
732 vistas21 diapositivas
Selenium Concepts por
Selenium ConceptsSelenium Concepts
Selenium ConceptsSwati Bansal
13.1K vistas40 diapositivas
Automation Testing using Selenium Webdriver por
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverPankaj Biswas
897 vistas36 diapositivas
Automation Testing by Selenium Web Driver por
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverCuelogic Technologies Pvt. Ltd.
27.1K vistas56 diapositivas
Selenium WebDriver with Java por
Selenium WebDriver with JavaSelenium WebDriver with Java
Selenium WebDriver with JavaFayis-QA
191 vistas31 diapositivas

Más contenido relacionado

La actualidad más candente

Interview Question & Answers for Selenium Freshers | LearningSlot por
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotLearning Slot
270 vistas22 diapositivas
Selenium - The page object pattern por
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object patternMichael Palotas
1.5K vistas22 diapositivas
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot por
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotInterview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotLearning Slot
256 vistas12 diapositivas
Selenium Basics Tutorial por
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics TutorialClever Moe
41.6K vistas17 diapositivas
Selenium webdriver interview questions and answers por
Selenium webdriver interview questions and answersSelenium webdriver interview questions and answers
Selenium webdriver interview questions and answersITeLearn
15.2K vistas40 diapositivas
Selenium ide made easy por
Selenium ide made easySelenium ide made easy
Selenium ide made easyNarayanan Palani
852 vistas27 diapositivas

La actualidad más candente(19)

Interview Question & Answers for Selenium Freshers | LearningSlot por Learning Slot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
Learning Slot270 vistas
Selenium - The page object pattern por Michael Palotas
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
Michael Palotas1.5K vistas
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot por Learning Slot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotInterview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot
Learning Slot256 vistas
Selenium Basics Tutorial por Clever Moe
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics Tutorial
Clever Moe41.6K vistas
Selenium webdriver interview questions and answers por ITeLearn
Selenium webdriver interview questions and answersSelenium webdriver interview questions and answers
Selenium webdriver interview questions and answers
ITeLearn15.2K vistas
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train... por Edureka!
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...
Edureka!4K vistas
Automation framework using selenium webdriver with java por Narayanan Palani
Automation framework using selenium webdriver with javaAutomation framework using selenium webdriver with java
Automation framework using selenium webdriver with java
Narayanan Palani1.3K vistas
Selenium ide1 por mindqqa
Selenium ide1Selenium ide1
Selenium ide1
mindqqa543 vistas
Selenium por eduquer
SeleniumSelenium
Selenium
eduquer159 vistas
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup por Dave Haeffner
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner3.9K vistas
Selenium Webdriver Interview Questions por Jai Singh
Selenium Webdriver Interview QuestionsSelenium Webdriver Interview Questions
Selenium Webdriver Interview Questions
Jai Singh896 vistas
How to Configure Selenium WebDriver (java) por Dasun Eranthika
How to Configure Selenium WebDriver (java)How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)
Dasun Eranthika7.1K vistas
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando... por Applitools
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Applitools1.2K vistas

Similar a Selenium

Selenium por
SeleniumSelenium
SeleniumSun Technlogies
399 vistas37 diapositivas
selenium.ppt por
selenium.pptselenium.ppt
selenium.pptrajnexient
4 vistas37 diapositivas
selenium.ppt por
selenium.pptselenium.ppt
selenium.pptAmenSheikh
6 vistas37 diapositivas
selenium.ppt por
selenium.pptselenium.ppt
selenium.pptssuser7b4894
7 vistas37 diapositivas
Selenium por
SeleniumSelenium
Seleniumhusnara mohammad
231 vistas36 diapositivas
Web UI Tests: Introduce UI tests using Selenium por
Web UI Tests: Introduce UI tests using Selenium Web UI Tests: Introduce UI tests using Selenium
Web UI Tests: Introduce UI tests using Selenium Peyman Fakharian
88 vistas26 diapositivas

Similar a Selenium(20)

Web UI Tests: Introduce UI tests using Selenium por Peyman Fakharian
Web UI Tests: Introduce UI tests using Selenium Web UI Tests: Introduce UI tests using Selenium
Web UI Tests: Introduce UI tests using Selenium
Peyman Fakharian88 vistas
#2 integration + ui tests por eleksdev
#2 integration + ui tests#2 integration + ui tests
#2 integration + ui tests
eleksdev1.6K vistas
Automated Web Testing using JavaScript por Simon Guest
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
Simon Guest73.6K vistas
Selenium -Test automation for web applications por AnisGhelissi
Selenium -Test automation for web applicationsSelenium -Test automation for web applications
Selenium -Test automation for web applications
AnisGhelissi144 vistas
Whys and Hows of Automation por vodQA
Whys and Hows of AutomationWhys and Hows of Automation
Whys and Hows of Automation
vodQA322 vistas
Selenium & PHPUnit made easy with Steward (Berlin, April 2017) por Ondřej Machulda
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Ondřej Machulda1.4K vistas
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени... por QAFest
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QAFest1.6K vistas
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS! por Puneet Kala
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala2.6K vistas
Selenium withnet por Vlad Maniak
Selenium withnetSelenium withnet
Selenium withnet
Vlad Maniak414 vistas
Selenium Automation Testing Interview Questions And Answers por Ajit Jadhav
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
Ajit Jadhav1.1K vistas
Selenium por Kalyan ch
SeleniumSelenium
Selenium
Kalyan ch6.4K vistas
Steps to write Selenium por Rohit Thakur
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
Rohit Thakur629 vistas

Último

Create a Structure in VBNet.pptx por
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptxBreach_P
72 vistas8 diapositivas
Use of Probiotics in Aquaculture.pptx por
Use of Probiotics in Aquaculture.pptxUse of Probiotics in Aquaculture.pptx
Use of Probiotics in Aquaculture.pptxAKSHAY MANDAL
95 vistas15 diapositivas
Recap of our Class por
Recap of our ClassRecap of our Class
Recap of our ClassCorinne Weisgerber
74 vistas15 diapositivas
Narration ppt.pptx por
Narration  ppt.pptxNarration  ppt.pptx
Narration ppt.pptxTARIQ KHAN
131 vistas24 diapositivas
Narration lesson plan.docx por
Narration lesson plan.docxNarration lesson plan.docx
Narration lesson plan.docxTARIQ KHAN
108 vistas11 diapositivas
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively por
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyPECB
574 vistas18 diapositivas

Último(20)

Create a Structure in VBNet.pptx por Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P72 vistas
Use of Probiotics in Aquaculture.pptx por AKSHAY MANDAL
Use of Probiotics in Aquaculture.pptxUse of Probiotics in Aquaculture.pptx
Use of Probiotics in Aquaculture.pptx
AKSHAY MANDAL95 vistas
Narration ppt.pptx por TARIQ KHAN
Narration  ppt.pptxNarration  ppt.pptx
Narration ppt.pptx
TARIQ KHAN131 vistas
Narration lesson plan.docx por TARIQ KHAN
Narration lesson plan.docxNarration lesson plan.docx
Narration lesson plan.docx
TARIQ KHAN108 vistas
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively por PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 574 vistas
Psychology KS4 por WestHatch
Psychology KS4Psychology KS4
Psychology KS4
WestHatch76 vistas
JiscOAWeek_LAIR_slides_October2023.pptx por Jisc
JiscOAWeek_LAIR_slides_October2023.pptxJiscOAWeek_LAIR_slides_October2023.pptx
JiscOAWeek_LAIR_slides_October2023.pptx
Jisc93 vistas
Structure and Functions of Cell.pdf por Nithya Murugan
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdf
Nithya Murugan455 vistas
The Open Access Community Framework (OACF) 2023 (1).pptx por Jisc
The Open Access Community Framework (OACF) 2023 (1).pptxThe Open Access Community Framework (OACF) 2023 (1).pptx
The Open Access Community Framework (OACF) 2023 (1).pptx
Jisc107 vistas
Solar System and Galaxies.pptx por DrHafizKosar
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptx
DrHafizKosar89 vistas
The basics - information, data, technology and systems.pdf por JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1106 vistas
Scope of Biochemistry.pptx por shoba shoba
Scope of Biochemistry.pptxScope of Biochemistry.pptx
Scope of Biochemistry.pptx
shoba shoba126 vistas
Psychology KS5 por WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch81 vistas
Class 10 English notes 23-24.pptx por TARIQ KHAN
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptx
TARIQ KHAN125 vistas
Ch. 7 Political Participation and Elections.pptx por Rommel Regala
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptx
Rommel Regala90 vistas

Selenium

  • 2. Outline Uniqueness of web app testing Heterogonous system Dynamic pages Load Security Selenium WebDriver Course project 4
  • 3. Web application architecture Heterogeneous system Front end  Browser: IE, Firefox, Chrome, Safari… Server side  Application Server  Database Server  File System  ……
  • 4. Heterogeneous system Front end HTML, JavaScript, Adobe Flash…… HTML JavaScript Page in Browser Source behind
  • 5. Heterogeneous system Should test all involved parts Everything can go wrong… However, only front end is accessible for tests Can not directly test the Server code and SQL Have to drive the execution and test  Frontend  HTML: Malformed HTML page? (demo)  JavaScript: Runtime Errors? (demo)  Server script  PHP, Java…: Runtime Errors? (demo)  SQL: Malformed SQL query string? (demo)
  • 6. Test from the front end Good things Hide the complexity of the backend Uniformed interface Can put a robot in the front end and automate the tests Bad things The front end is not trustable  Crafted malicious requests
  • 7. Good things of testing from the front end  Automated web app testing  Compare to commend-line program testing…  Sensitive to input values (the same)  GUI testing: event driven (the difference)  “Button A” then “Button B”  OK  “Button B” then “Button A”  FAIL  The robot should be able to  Provide input values  Simulate user actions  Selenium  A tool set automates web app testing across platforms  Can simulate user interactions in browser  Two components  Selenium IDE  Selenium WebDriver (aka. Selenium 2)
  • 8. Selenium IDE Firefox extension Easy record and replay Debug and set breakpoints Save tests in HTML, WebDriver and other formats.
  • 9. Selenium IDE test cases Selenium saves all information in an HTML table format Each record consists of: Command – tells Selenium what to do (e.g. “open”, “type”, “click”, “verifyText”) Target – tells Selenium which HTML element a command refers to (e.g. textbox, header, table) Value – used for any command that might need a value of some kind (e.g. type something into a textbox)
  • 10. How to record/replay with Selenium IDE 1. Start recording in Selenium IDE 2. Execute scenario on running web application 3. Stop recording in Selenium IDE 4. Verify / Add assertions 5. Replay the test. Selenium IDE Demo……
  • 11. Bad things of testing from the front end The front end is not trustable Front end code can be accessed to anybody They can infer the input parameters  Crafted requests! Demo Front end limits the length of the input values Front end limits the content of the input values Front end limits the combination of the input values
  • 12. Uniqueness 2: Dynamic pages Client page is dynamic  It can change itself in the runtime  HTML can be modified by JavaScript  JavaScript can modify itself  Demo Server script is dynamic  Client pages are constructed in the runtime  A same server script can produce completely different client pages  Demo  SchoolMate
  • 13. Uniqueness 3: Performance Performance is crucial to the success of a web app  Recall the experience to register for a class in the first days of the semester…  Are the servers powerful enough? Performance testing evaluates system performance under normal and heavy usage  Load testing  For expected concurrent number of users  Stress testing  To understand the upper limits of capacity Performance testing can be automated
  • 14. Uniqueness 4: Security Web app usually deals with sensitive info, e.g. Credit card number SSN Billing / Shipping address Security is the biggest concern Security testing should simulate possible attacks
  • 15. Uniqueness 4: Security SQL Injection The untrusted input is used to construct dynamic SQL queries. E.g, update my own password $str = "UPDATE users SET password = ” “ . $_POST['newPass’] . “” WHERE username =”“ . $_POST['username'] . “””; mysql_query( $str ); $_POST['newPass’] = pass, $_POST['username'] = me Query String: UPDATE users SET password = “pass” WHERE username =“me” $_POST['newPass’] = pass, $_POST['username'] = “ OR 1=1 -- Query String: UPDATE users SET password = “pass” WHERE username =“” OR 1=1 --” Normal Case Attack PHP ScriptPHP Script
  • 16. Uniqueness 4: Security Cross Site Scripting (XSS) The untrusted input is used to construct dynamic HTML pages. The malicious JS injected executes in victim’s browser The malicious JS can steal sensitive info Demo Solution: Never trust user inputs Design test cases to simulate attacks
  • 17. Outline Uniqueness of web app testing Heterogonous system Dynamic pages Load Security Selenium WebDriver Course project 4
  • 18. Limitation of Selenium IDE No multiple browsers support It runs only in Mozilla Firefox. No manual scripts E.g. conditions and Loops for Data Driven Testing Fancy test cases  Selenium WebDriver
  • 19. Selenium WebDriver (Selenium 2)  Selenium-WebDriver  A piece of program  Control the browser by programming  More flexible and powerful  Selenium-WebDriver supports multiple browsers in multiple platforms  Google Chrome 12.0.712.0+  Internet Explorer 6+  Firefox 3.0+  Opera 11.5+  Android – 2.3+ for phones and tablets  iOS 3+ for phones  iOS 3.2+ for tablets
  • 20. Selenium WebDriver WebDriver is designed to providing a simpler and uniformed programming interface Same WebDriver script runs for different platforms Support multiple programming language: Java, C#, Python, Ruby, PHP, Perl… It’s efficient WebDriver leverages each browser’s native support for automation.
  • 21. What Selenium can do A solution for the automated testing Simulate user actions Functional testing  Create regression tests to verify functionality and user acceptance. Browser compatibility testing  The same script can run on any Selenium platform Load testing Stress testing
  • 22. How to use Selenium WebDriver (1) Go to a page (2) Locate an element (3) Do something with that element ...... (i) Locate an element (i+1) Do something with that element (i+2) Verify / Assert the result
  • 23. Demo: Verify page title public static void main( String[] args ) { // Create a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); // (1) Go to a page driver.get("http://www.google.com"); // (2) Locate an element WebElement element = driver.findElement(By.name("q")); // (3-1) Enter something to search for element.sendKeys("Purdue Univeristy"); // (3-2) Now submit the form. WebDriver will find the form for us from the element element.submit(); // (3-3) Wait up to 10 seconds for a condition WebDriverWait waiting = new WebDriverWait(driver, 10); waiting.until( ExpectedConditions.presenceOfElementLocated( By.id("pnnext") ) ); // (4) Check the title of the page if( driver.getTitle().equals("purdue univeristy - Google Search") ) System.out.println("PASS"); else System.err.println("FAIL"); //Close the browser driver.quit(); }
  • 24. How to locate an element  By id  HTML: <div id="coolestWidgetEvah">...</div>  WebDriver:  driver.findElement( By.id("coolestWidgetEvah") );  By name  HTML: <input name="cheese" type="text"/>  WebDriver: driver.findElement( By.name("cheese") );  By Xpath  HTML  <html>  <input type="text" name="example" />  <input type="text" name="other" />  </html>  WebDriver: driver.findElements( By.xpath("//input") );  There are plug-ins for firefox/chrome to automatically display the Xpath 
  • 25. Timeissue There are delays between submitting a request and receiving the response We can wait until the response page is loaded Robot doesn’t know! In WebDriver, sometimes it doesn’t work if  Submit a request  Verify the response immediately Solution:  Simulate the wait. Wait until some HTML object appears  Demo
  • 26. Outline What to test for a web application Test web app with selenium What’s Selenium? Why Selenium? How to use Selenium Course project 4
  • 27. Course Project 4 Test a functionality without the source The subject web application “Add New Class” in “SchoolMate”
  • 28. Course Project 4 Part 1: overview Design test cases against the requirement  The tests should consider  all possible cases  equivalence class partitioning Implement Selenium WebDriver Script for “Add new class” Your testYour test casescases Your WebDriverYour WebDriver test templatetest template inputinput outputoutput TestTest resultsresults
  • 29. Part 1: requirement analysis Requirement for the “add” function After clicking the “Add class” button… [R-6] The class record added is successfully shown in the table. [R-7] The values are exactly the same as those were entered or selected.
  • 30. Part 1: Implement WebDriver Script  In WebDriver script, Simulate the user action Navigate to the subject page Enter values into textboxs based on input values Select options based on input values Click the “add class” button Check the result against the requirements Run all your test cases and report the results.
  • 31. Course Project 4 Part 2: Pair wise testing Use an existing pair wise testing tool fire-eye Largely you may reuse the WebDriver template in Part 1 Your testYour test casescases Your WebDriverYour WebDriver test templatetest template inputinput outputoutput TestTest resultresult Test casesTest cases generatedgenerated ConvertConvert