SlideShare a Scribd company logo
Software Testing Lab
(Lab 3 & 4)
By: Ms. Aroosa Hameed
DEPARTMENT OF SOFTWARE ENGINEERING (DSE)
Foundation University Rawalpindi Campus (FURC)
Lab Agenda
• Selenium IDE in depth (commands, target, value).
• Locating Strategies.
• By identifiers.
• By Id.
• By Name.
• By link.
• By Xpath.
SEN 461L - Software Testing Lab by Aroosa Hameed 2
Command, Target, Value fields
• A test case is represented by a table view.
• Each row in a table represents a step and it contains 3 columns as described
below:
 Command: Specifies the action to be performed by step.
 Target: Specifies web element for the action.
 Value: Specifies the input data or value for the step.
SEN 461L - Software Testing Lab by Aroosa Hameed 3
Command, Target, Value fields (Cont.)
• Technically, the columns Command, target, and value are like:
𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑎𝑟𝑔1, 𝑎𝑟𝑔2
• All these columns, fields are case sensitive.
• One major drawback is that you are limited to maximum two arguments.
SEN 461L - Software Testing Lab by Aroosa Hameed 4
Locating Strategies
• For many Selenium commands, target is required.
• Target identifies a web element uniquely in the content of web application.
• Web elements: Buttons, input elements, links, images etc.
• Target consists of locating strategy and format like:
LocatorType=LocatorStrategy
Example:
id=uh-search-box
SEN 461L - Software Testing Lab by Aroosa Hameed 5
Locating by identifiers
• It was default type earlier and not recommended as it is not supported by web
driver.
• The first element with matching id attribute is used.
• If no element has a matching id attribute then the first element with a matching
name attribute is used.
• Example: identifier=login (this could be id or name)
SEN 461L - Software Testing Lab by Aroosa Hameed 6
Locating by id
• This type of locator is more explicit and the first element with the matching id
attribute is used.
• Use this when you know an element’s id attribute.
• Example: id =login
id=user name
SEN 461L - Software Testing Lab by Aroosa Hameed 7
Locating by name
• The name locator type will locate first element with a matching name attribute.
• Example: name=username.
SEN 461L - Software Testing Lab by Aroosa Hameed 8
Locating Hyperlinks by Link Text
• This is a simple method of locating a hyperlink in your web page.
• The text of link is used for this purpose.
• If two links with same text are present, then the first match will be used.
• Example:
link=SignIn.
SEN 461L - Software Testing Lab by Aroosa Hameed 9
Locating by XPath
• XPath is a language used for locating nodes in XML documents.
• One of the main reason for using XPath is when you don’t have a suitable id or
name attribute for the element you want to locate.
1. XPath-Absolute---not recommended to use
Syntax:
//html/body/tag1[index]/tag2[index]/…/tagN[index]
Example:
//html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]
SEN 461L - Software Testing Lab by Aroosa Hameed 10
Locating by XPath
2. XPath-Attributes
Syntax:
//htmltag[@attribute1=‘value1’ and @attribute2=‘value2’]
Example:
//input[@id=‘password’ and @placeholder=‘Password’]
SEN 461L - Software Testing Lab by Aroosa Hameed 11
Locating by XPath
2. XPath-Functions
If you have some part of id/name as constant and rest is changing and rest is
changing, you can use Xpath functions contains or starts-with based on the context.
Example:
//input[contains(@id,‘username’)] matches first element with username in id.
//input[starts-with(@name,‘pass’)] matches first element with name starting with
‘pass’ word.
SEN 461L - Software Testing Lab by Aroosa Hameed 12
Exercise
1. By id
2. By name
3. By link
4. Xpath-Attribute
//input[@id=‘password’ and @placeholder=‘Password’]
5. Xpath-Function
//input[contains(@id,‘username’)].
SEN 461L - Software Testing Lab by Aroosa Hameed 13

More Related Content

PPTX
Semantic DEX Components
PPTX
Java annotations
PPT
Email Data Cleaning
PDF
Nose Dive into Apache Spark ML
PPTX
Mining Code Examples with Descriptive Text from Software Artifacts
PPTX
Advance java session 14
PPTX
Methods in c# (1)
PDF
Semantic DEX Components
Java annotations
Email Data Cleaning
Nose Dive into Apache Spark ML
Mining Code Examples with Descriptive Text from Software Artifacts
Advance java session 14
Methods in c# (1)

What's hot (20)

PPTX
PCSTt11 overview of java
DOC
PPTX
Similarity computation exploiting the semantic and syntactic inherent structu...
PPTX
Reading and writting
PPT
PDF
JetBrains MPS: Typesystem Aspect
PDF
Introduction [1] - Software Testing Techniques (CIS640)
PDF
.Net Classes and Objects | UiPath Community
PPT
Mining Product Reputations On the Web
PPTX
9781337102087 ppt ch04
PDF
Lecture02 java
PPT
JavaScript Introductin to Functions
PDF
IRE- Algorithm Name Detection in Research Papers
PPTX
Java tokens
PPTX
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
PDF
Extracts from "Clean code"
PPTX
PPT
Equivalence partitions analysis
PCSTt11 overview of java
Similarity computation exploiting the semantic and syntactic inherent structu...
Reading and writting
JetBrains MPS: Typesystem Aspect
Introduction [1] - Software Testing Techniques (CIS640)
.Net Classes and Objects | UiPath Community
Mining Product Reputations On the Web
9781337102087 ppt ch04
Lecture02 java
JavaScript Introductin to Functions
IRE- Algorithm Name Detection in Research Papers
Java tokens
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Extracts from "Clean code"
Equivalence partitions analysis
Ad

Similar to Software testing lab 3 & 4 (2) (20)

PPTX
Automatedtestingwithselenium shubham jain
PPTX
Automation Testing by Selenium Web Driver
PPTX
Automated_Testing_Selenium
PPTX
Locators and webdriver commands Selenium Session2.pptx
PPTX
Automation Testing
PDF
How to use selenium locators effectively for web automation.pdf
PDF
Using XPath in Selenium - All you need to know.pdf
PDF
Efficient Rails Test-Driven Development - Week 6
PDF
2010 07-18.wa.rails tdd-6
PPTX
Automated testing with selenium prasad bapatla
PPTX
Selenium
PPT
Web testing with selenium and by quontra solutions
PDF
Selenium Introduction by Sandeep Sharda
PPTX
Selenium ppt
PDF
Selenium
PDF
Selenium Overview
PPTX
Selenium training
PPTX
Selenium WebDriver training
PDF
Real World Selenium
PPTX
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
Automatedtestingwithselenium shubham jain
Automation Testing by Selenium Web Driver
Automated_Testing_Selenium
Locators and webdriver commands Selenium Session2.pptx
Automation Testing
How to use selenium locators effectively for web automation.pdf
Using XPath in Selenium - All you need to know.pdf
Efficient Rails Test-Driven Development - Week 6
2010 07-18.wa.rails tdd-6
Automated testing with selenium prasad bapatla
Selenium
Web testing with selenium and by quontra solutions
Selenium Introduction by Sandeep Sharda
Selenium ppt
Selenium
Selenium Overview
Selenium training
Selenium WebDriver training
Real World Selenium
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
Ad

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Institutional Correction lecture only . . .
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Lesson notes of climatology university.
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
102 student loan defaulters named and shamed – Is someone you know on the list?
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
RMMM.pdf make it easy to upload and study
O7-L3 Supply Chain Operations - ICLT Program
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Sports Quiz easy sports quiz sports quiz
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Anesthesia in Laparoscopic Surgery in India
Institutional Correction lecture only . . .
Renaissance Architecture: A Journey from Faith to Humanism
Supply Chain Operations Speaking Notes -ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
TR - Agricultural Crops Production NC III.pdf
01-Introduction-to-Information-Management.pdf
Microbial disease of the cardiovascular and lymphatic systems
Abdominal Access Techniques with Prof. Dr. R K Mishra
Lesson notes of climatology university.
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

Software testing lab 3 & 4 (2)

  • 1. Software Testing Lab (Lab 3 & 4) By: Ms. Aroosa Hameed DEPARTMENT OF SOFTWARE ENGINEERING (DSE) Foundation University Rawalpindi Campus (FURC)
  • 2. Lab Agenda • Selenium IDE in depth (commands, target, value). • Locating Strategies. • By identifiers. • By Id. • By Name. • By link. • By Xpath. SEN 461L - Software Testing Lab by Aroosa Hameed 2
  • 3. Command, Target, Value fields • A test case is represented by a table view. • Each row in a table represents a step and it contains 3 columns as described below:  Command: Specifies the action to be performed by step.  Target: Specifies web element for the action.  Value: Specifies the input data or value for the step. SEN 461L - Software Testing Lab by Aroosa Hameed 3
  • 4. Command, Target, Value fields (Cont.) • Technically, the columns Command, target, and value are like: 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑎𝑟𝑔1, 𝑎𝑟𝑔2 • All these columns, fields are case sensitive. • One major drawback is that you are limited to maximum two arguments. SEN 461L - Software Testing Lab by Aroosa Hameed 4
  • 5. Locating Strategies • For many Selenium commands, target is required. • Target identifies a web element uniquely in the content of web application. • Web elements: Buttons, input elements, links, images etc. • Target consists of locating strategy and format like: LocatorType=LocatorStrategy Example: id=uh-search-box SEN 461L - Software Testing Lab by Aroosa Hameed 5
  • 6. Locating by identifiers • It was default type earlier and not recommended as it is not supported by web driver. • The first element with matching id attribute is used. • If no element has a matching id attribute then the first element with a matching name attribute is used. • Example: identifier=login (this could be id or name) SEN 461L - Software Testing Lab by Aroosa Hameed 6
  • 7. Locating by id • This type of locator is more explicit and the first element with the matching id attribute is used. • Use this when you know an element’s id attribute. • Example: id =login id=user name SEN 461L - Software Testing Lab by Aroosa Hameed 7
  • 8. Locating by name • The name locator type will locate first element with a matching name attribute. • Example: name=username. SEN 461L - Software Testing Lab by Aroosa Hameed 8
  • 9. Locating Hyperlinks by Link Text • This is a simple method of locating a hyperlink in your web page. • The text of link is used for this purpose. • If two links with same text are present, then the first match will be used. • Example: link=SignIn. SEN 461L - Software Testing Lab by Aroosa Hameed 9
  • 10. Locating by XPath • XPath is a language used for locating nodes in XML documents. • One of the main reason for using XPath is when you don’t have a suitable id or name attribute for the element you want to locate. 1. XPath-Absolute---not recommended to use Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index] Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1] SEN 461L - Software Testing Lab by Aroosa Hameed 10
  • 11. Locating by XPath 2. XPath-Attributes Syntax: //htmltag[@attribute1=‘value1’ and @attribute2=‘value2’] Example: //input[@id=‘password’ and @placeholder=‘Password’] SEN 461L - Software Testing Lab by Aroosa Hameed 11
  • 12. Locating by XPath 2. XPath-Functions If you have some part of id/name as constant and rest is changing and rest is changing, you can use Xpath functions contains or starts-with based on the context. Example: //input[contains(@id,‘username’)] matches first element with username in id. //input[starts-with(@name,‘pass’)] matches first element with name starting with ‘pass’ word. SEN 461L - Software Testing Lab by Aroosa Hameed 12
  • 13. Exercise 1. By id 2. By name 3. By link 4. Xpath-Attribute //input[@id=‘password’ and @placeholder=‘Password’] 5. Xpath-Function //input[contains(@id,‘username’)]. SEN 461L - Software Testing Lab by Aroosa Hameed 13