SlideShare a Scribd company logo
1 of 11
Experiment 15
Performing Testing by using CSS Selector Locators in Selenium IDE
CLO-1: Construct the experiments/projects of varying complexities
CLO-2: Use modern tools to solve problems of varying complexities in software
testing.
CLO-3: Construct the projects of varying complexities using different software
testing techniques
CLO-4: Demonstrate a unique solution of problem under discussion
CSS Selector Locator in Selenium IDE
It used to identify the web element based on HTML tag, id, class, and attributes.
To describe the look and formatting of a document written in the markup language are known as CSS
[Cascading Style Sheets].
CSS has capabilities to locate an element having no ID, class, or name, just like Xpath.
It works in six different scenarios to identify and locate the web elements.
1. Locating by ID
2. Locating by Class
3. Locating by Attribute
4. Locating by ID/Class & Attribute
5. Locating by Sub-string
6. Locating by inner text
1: CSS Selector: ID
The id attribute is used to identify the web element uniquely in the web pages.
Syntax of ID Attribute:
[HTML tag][#][Value of ID attribute]
The hash sign (#): it is mandatory while using the ID attribute to create a CSS Selector.
Always remember that the prefix with ‘css=’ is usedto specify a CSS Selector in the target text box
of Selenium IDE.
We will take an example of Email text box present in login form at facbook.com
 The email text box has an id attribute whose value defined as an id=email.
 ID attribute and value can be used to create a CSS Selector to access the email textbox.
 Launch the browser.
 And type https://www.facebook.com in Google search box; it will redirect you to the
Facebook login page.
 When we are inspecting the web element of an email text box, and its html tag value is input,
and the value of id attribute is email.
To verify the locator:
 Open the Test Script Editor Box in Selenium –IDE and click on the command text box.
 And write command as:
Command =verify element present
Value = css=input#Email
 Click on the Find button.
 To verify that the value of a locator is correct or not, you can also check in the browser
that the Email Text box is highlighted or not.
2: CSS Selector: Class
Identify a web element with the help of Class as a CSS Selector is like using id attribute. The only
difference between Class and id is in their syntax.
The value of a class attribute is used to access the web element.
Syntax of Class Attribute:
css= [HTML tag][.][Value of class attributes]
[.]: Itis mandatory while using a Class attribute to create a CSS Selector.
We will take an example of an Email text box present in the login form of facbook.com
 Launch the browser.
 And type https://www.facebook.com in Google search box; it will redirect you to the
Facebook login page.
 Where you inspect the email text box web element and notice that the html tag is input and
the value of the class attribute is input.login_form_input_box
To verify the locator
 Open the Test Script Editor Box in selenium IDE and click on the command text box,
And write command as:
Command =verify element present
Value = css=input.login_form_input_box
 Click on the Find button.
 To verify that the value of a locator is correct or not, you can check in a browser that the
Email Text box is highlighted or not.
NOTE: When multiple elements have the same HTML tag and name, then only the first element in
source code will be considered.
For example, both email and the password text box have the same class name as: “input text
login_form_input_box.”
In this case, the email text box is the first element, so the source code of this element would be
considered first.
3: CSS Selector: Attribute
 Locating the attribute of a CSS selector, we would access the Password textbox,
which is present in the login form of Facebook.
 The Password textbox has a type attribute whose value defined as pass.
 To create a CSS Selector attribute, we can use value, type, and name.
Syntax of CSS Selector Attribute:
css=<HTML tag>< [attribute=Value of attribute]>
Value of attribute: It denotes the value which accesses at the time of using the attribute.
Let see an example of an Attribute:
We are locating a web element by defining the CSS Selector for that particular web element.
 Open the browser.
 And type https://www.facebook.com in Google search box; it will redirect you to the
Facebook login page.
 And you can inspect the password text box’s web element and notice that the html
tag value is input and the value of name attribute is pass.
To verify the locator value:
 Open the Test Script Editor Box in selenium IDE and click on the command text box,
and write command as:
Command =verify element present
Value = css=input [name=’pass’]
 To verify the value of a locator is correct or not, click on the Find button in the
selenium IDE interface and check in a browser that the password Text box
highlighted.
4:CSS SELECTOR: ID/Class and Attribute
The Id, class, and attribute of CSS selector are used to identify the web element to access
the web pages.
Syntax for Id/Class and Attribute:
css=<HTML tag><./#><value of Class / ID attribute> {[attribute=Value of attribute]}
[#]: It is used to present an ID attribute. It is mandatory while using the ID attribute to
create a CSS selector.
[.]: It is used to display a Class attribute. It is necessary while using a class attribute to create
a CSS Selector.
Value of Class or ID attributes: It access by the value of ID/Class and attribute.
In this section, < [attribute=Value of attribute]> we can use value, type and name as an
Attribute.
Value of attribute: It denotes the value of an attribute which is used to locate the web
element.
Let see an example of an ID/ Class and Attribute
Locating ID/Class and attribute of CSS selector, we would access the Password textbox
present in the login form at the Facebook.
 Launch the browser.
 And type https://www.facebook.com in Google search box.
 It will redirect you to the Facebook login page.
Where HTML tag value is [input], attributes are ID and type, and their parallel values
are [Pass] and [password], and all of them together make a reference to
the [Password] textbox.
Verify the locator value:
 Type css=input#Pass[name=’Pass’] i.e. the locator value in the target box in the
Selenium IDE.
 To verify the value of a locator is correct or not, click on the Find button in the
selenium IDE interface.
 And check in a browser that the password Text box is highlighted or not.
5: CSS Selector: Sub String
CSS Selector Sub-string is used to match a partial string to locate a particular web element.
There are three ways to match a substring using a CSS Selector.
 Match a prefix
 Match a suffix
 Match a substring
Now we will discuss each of them in details with an example,
MATCH A PREFIX:
 It will access a particular string using a ‘match a prefix’.
Syntax of Prefix:
css= [HTML tag]{[attribute^=prefix of the string]}.
[^]: It is a symbolic notation to match a string using a prefix.
A prefix of the string: matching operation performed based on a string.
 For example, we will define the CSS Selector for the Email text box of a Facebook login
page as css=input#email[name^=’em’]
 Click on the Find button to verify whether the defined CSS Selector locates the desired
element or not.
MATCH A SUFFIX:
 It will access a particular string using a ‘match a suffix’.
Syntax of Suffix:
css= [HTML tag]{[attribute$=suffix of the string]}
[$]: This is a symbolic notation to match a string using a suffix.
Suffix of the string: matching operation performed based on a string.
 For example, we will define the CSS Selector for the Email text box of the Facebook login
page.
css=input#email[name*=’ail’]
 Click on the Find button to verify whether the defined CSS Selector locates the desired
element or not.
MATCH A SUBSTRING:
 It will access a particular string using a ‘match a substring’.
Syntax of substring:
css=<HTML tag><[attribute*=sub string]>
[*]:It is Symbolic notation to match a string using substring.
Substring: matching operation is performed based on a string
 For example, we will define the CSS Selector for the Email text box of the Facebook login
page as css=input#email[name*=’ail’]
 Click on the Find button to verify whether the defined CSS Selector locates the desired
element or not.
6: CSS Selector: Inner text
The inner text is used to identify and create a CSS Selector using a string pattern of the HTML tag
which is displayed on the web page.
Syntax of inner text:
css=[HTML tag]<[:][contains][(inner text)]
[:]:- It is used to symbolize contains method.
Contains: It will include the value of a Class attribute.
Text: The text that is displayed anywhere on the web page irrespective of its location.
Inner text is one of the most frequently used locating technique to identify the web element because
of the simplified syntax.
Task :
Use the inner text to identify and create a CSS Selector using a string
pattern of the HTML tag displayed on the web page.(you can use any web
page )

More Related Content

Similar to ST LAB 15 (1).docx

CSS Foundations, pt 1
CSS Foundations, pt 1CSS Foundations, pt 1
CSS Foundations, pt 1Shawn Calvert
 
CSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box ModelCSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box Modeljamiecavanaugh
 
Real Browser Check Scripting Guide - Rigor Monitoring
Real Browser Check Scripting Guide - Rigor MonitoringReal Browser Check Scripting Guide - Rigor Monitoring
Real Browser Check Scripting Guide - Rigor MonitoringAnthony Ferrari
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxLecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxGmachImen
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Erin M. Kidwell
 
Web 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style SheetsWeb 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style SheetsMohammad Imam Hossain
 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jqueryvaluebound
 
Documentation For Tab Setup
Documentation For Tab SetupDocumentation For Tab Setup
Documentation For Tab Setupvkeeton
 
Introducing CSS Selectors.docx
Introducing CSS Selectors.docxIntroducing CSS Selectors.docx
Introducing CSS Selectors.docxDr. Somnath Sinha
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS PresentationShawn Calvert
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationLecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationZahouAmel1
 

Similar to ST LAB 15 (1).docx (20)

css.ppt
css.pptcss.ppt
css.ppt
 
CSS Foundations, pt 1
CSS Foundations, pt 1CSS Foundations, pt 1
CSS Foundations, pt 1
 
CSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box ModelCSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box Model
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
Real Browser Check Scripting Guide - Rigor Monitoring
Real Browser Check Scripting Guide - Rigor MonitoringReal Browser Check Scripting Guide - Rigor Monitoring
Real Browser Check Scripting Guide - Rigor Monitoring
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxLecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptx
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
 
Web 101
Web 101Web 101
Web 101
 
Web 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style SheetsWeb 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style Sheets
 
CSS
CSSCSS
CSS
 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jquery
 
Css
CssCss
Css
 
Documentation For Tab Setup
Documentation For Tab SetupDocumentation For Tab Setup
Documentation For Tab Setup
 
Introducing CSS Selectors.docx
Introducing CSS Selectors.docxIntroducing CSS Selectors.docx
Introducing CSS Selectors.docx
 
Less css
Less cssLess css
Less css
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationLecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType Classification
 
Web day01 MOL.pdf
Web day01 MOL.pdfWeb day01 MOL.pdf
Web day01 MOL.pdf
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
Web Development 4
Web Development 4Web Development 4
Web Development 4
 

Recently uploaded

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

ST LAB 15 (1).docx

  • 1. Experiment 15 Performing Testing by using CSS Selector Locators in Selenium IDE CLO-1: Construct the experiments/projects of varying complexities CLO-2: Use modern tools to solve problems of varying complexities in software testing. CLO-3: Construct the projects of varying complexities using different software testing techniques CLO-4: Demonstrate a unique solution of problem under discussion
  • 2. CSS Selector Locator in Selenium IDE It used to identify the web element based on HTML tag, id, class, and attributes. To describe the look and formatting of a document written in the markup language are known as CSS [Cascading Style Sheets]. CSS has capabilities to locate an element having no ID, class, or name, just like Xpath. It works in six different scenarios to identify and locate the web elements. 1. Locating by ID 2. Locating by Class 3. Locating by Attribute 4. Locating by ID/Class & Attribute 5. Locating by Sub-string 6. Locating by inner text 1: CSS Selector: ID The id attribute is used to identify the web element uniquely in the web pages. Syntax of ID Attribute: [HTML tag][#][Value of ID attribute] The hash sign (#): it is mandatory while using the ID attribute to create a CSS Selector. Always remember that the prefix with ‘css=’ is usedto specify a CSS Selector in the target text box of Selenium IDE. We will take an example of Email text box present in login form at facbook.com  The email text box has an id attribute whose value defined as an id=email.  ID attribute and value can be used to create a CSS Selector to access the email textbox.  Launch the browser.  And type https://www.facebook.com in Google search box; it will redirect you to the Facebook login page.  When we are inspecting the web element of an email text box, and its html tag value is input, and the value of id attribute is email.
  • 3. To verify the locator:  Open the Test Script Editor Box in Selenium –IDE and click on the command text box.  And write command as: Command =verify element present Value = css=input#Email  Click on the Find button.  To verify that the value of a locator is correct or not, you can also check in the browser that the Email Text box is highlighted or not. 2: CSS Selector: Class Identify a web element with the help of Class as a CSS Selector is like using id attribute. The only difference between Class and id is in their syntax. The value of a class attribute is used to access the web element. Syntax of Class Attribute: css= [HTML tag][.][Value of class attributes]
  • 4. [.]: Itis mandatory while using a Class attribute to create a CSS Selector. We will take an example of an Email text box present in the login form of facbook.com  Launch the browser.  And type https://www.facebook.com in Google search box; it will redirect you to the Facebook login page.  Where you inspect the email text box web element and notice that the html tag is input and the value of the class attribute is input.login_form_input_box To verify the locator  Open the Test Script Editor Box in selenium IDE and click on the command text box, And write command as: Command =verify element present Value = css=input.login_form_input_box  Click on the Find button.  To verify that the value of a locator is correct or not, you can check in a browser that the Email Text box is highlighted or not.
  • 5. NOTE: When multiple elements have the same HTML tag and name, then only the first element in source code will be considered. For example, both email and the password text box have the same class name as: “input text login_form_input_box.” In this case, the email text box is the first element, so the source code of this element would be considered first.
  • 6. 3: CSS Selector: Attribute  Locating the attribute of a CSS selector, we would access the Password textbox, which is present in the login form of Facebook.  The Password textbox has a type attribute whose value defined as pass.  To create a CSS Selector attribute, we can use value, type, and name. Syntax of CSS Selector Attribute: css=<HTML tag>< [attribute=Value of attribute]> Value of attribute: It denotes the value which accesses at the time of using the attribute. Let see an example of an Attribute: We are locating a web element by defining the CSS Selector for that particular web element.  Open the browser.  And type https://www.facebook.com in Google search box; it will redirect you to the Facebook login page.  And you can inspect the password text box’s web element and notice that the html tag value is input and the value of name attribute is pass. To verify the locator value:
  • 7.  Open the Test Script Editor Box in selenium IDE and click on the command text box, and write command as: Command =verify element present Value = css=input [name=’pass’]  To verify the value of a locator is correct or not, click on the Find button in the selenium IDE interface and check in a browser that the password Text box highlighted. 4:CSS SELECTOR: ID/Class and Attribute The Id, class, and attribute of CSS selector are used to identify the web element to access the web pages. Syntax for Id/Class and Attribute: css=<HTML tag><./#><value of Class / ID attribute> {[attribute=Value of attribute]} [#]: It is used to present an ID attribute. It is mandatory while using the ID attribute to create a CSS selector. [.]: It is used to display a Class attribute. It is necessary while using a class attribute to create a CSS Selector. Value of Class or ID attributes: It access by the value of ID/Class and attribute. In this section, < [attribute=Value of attribute]> we can use value, type and name as an Attribute.
  • 8. Value of attribute: It denotes the value of an attribute which is used to locate the web element. Let see an example of an ID/ Class and Attribute Locating ID/Class and attribute of CSS selector, we would access the Password textbox present in the login form at the Facebook.  Launch the browser.  And type https://www.facebook.com in Google search box.  It will redirect you to the Facebook login page. Where HTML tag value is [input], attributes are ID and type, and their parallel values are [Pass] and [password], and all of them together make a reference to the [Password] textbox. Verify the locator value:  Type css=input#Pass[name=’Pass’] i.e. the locator value in the target box in the Selenium IDE.  To verify the value of a locator is correct or not, click on the Find button in the selenium IDE interface.
  • 9.  And check in a browser that the password Text box is highlighted or not. 5: CSS Selector: Sub String CSS Selector Sub-string is used to match a partial string to locate a particular web element. There are three ways to match a substring using a CSS Selector.  Match a prefix  Match a suffix  Match a substring Now we will discuss each of them in details with an example, MATCH A PREFIX:  It will access a particular string using a ‘match a prefix’. Syntax of Prefix: css= [HTML tag]{[attribute^=prefix of the string]}. [^]: It is a symbolic notation to match a string using a prefix. A prefix of the string: matching operation performed based on a string.  For example, we will define the CSS Selector for the Email text box of a Facebook login page as css=input#email[name^=’em’]  Click on the Find button to verify whether the defined CSS Selector locates the desired element or not.
  • 10. MATCH A SUFFIX:  It will access a particular string using a ‘match a suffix’. Syntax of Suffix: css= [HTML tag]{[attribute$=suffix of the string]} [$]: This is a symbolic notation to match a string using a suffix. Suffix of the string: matching operation performed based on a string.  For example, we will define the CSS Selector for the Email text box of the Facebook login page. css=input#email[name*=’ail’]  Click on the Find button to verify whether the defined CSS Selector locates the desired element or not. MATCH A SUBSTRING:  It will access a particular string using a ‘match a substring’. Syntax of substring: css=<HTML tag><[attribute*=sub string]> [*]:It is Symbolic notation to match a string using substring. Substring: matching operation is performed based on a string
  • 11.  For example, we will define the CSS Selector for the Email text box of the Facebook login page as css=input#email[name*=’ail’]  Click on the Find button to verify whether the defined CSS Selector locates the desired element or not. 6: CSS Selector: Inner text The inner text is used to identify and create a CSS Selector using a string pattern of the HTML tag which is displayed on the web page. Syntax of inner text: css=[HTML tag]<[:][contains][(inner text)] [:]:- It is used to symbolize contains method. Contains: It will include the value of a Class attribute. Text: The text that is displayed anywhere on the web page irrespective of its location. Inner text is one of the most frequently used locating technique to identify the web element because of the simplified syntax. Task : Use the inner text to identify and create a CSS Selector using a string pattern of the HTML tag displayed on the web page.(you can use any web page )