SlideShare a Scribd company logo
1 of 14
Advance Xpath Processing



     Suresh
What is Xpath

 XPath is a syntax used for selecting parts of an
                XML document

 The way XPath describes paths to elements is
similar to the way an operating system describes
                  paths to files

XPath is almost a small programming language; it
          has functions and expressions
            XPath is a W3C standard
Html page
Using contains to search text
Using starts-with to search attribute value




            /html/body/div/table[3]/tbody/tr/td
Using Operator



//div[contains(@class,'pagination')]//a[contains(.,'>') and not(contains(.,'|'))]
Using Functions




       //td[contains(.,'Chapter')][position() =2]
       //td[contains(.,'Chapter')][2]
Axes (outline View)
Starting from a given node, the self, preceding, following, ancestor,
and descendant axes form a partition of all the nodes
Axes (outline View)
    Self




Preceding
Axes (outline View)
    Following




 Ancestor
Axes (outline View)
   Descendant
Selecting using xpath
                        Selecting from dropdown list
driver.findElement(By.xpath("//select/option[contains(.,'pc')]"))


                        Selecting radio button

 driver.findElement(By.xpath("//input[contains(@id,'red')
 and @type='radio']")).click();


                           Selecting checkbox
  driver.findElement(By.xpath("//input[contains(@name,'vehicle')
 and contains(@value,'Nothing')]")).click();
Advantage of smart xpath processing
                Test case to click first chapter
driver.findElement(By.xpath(“/html/body/div/table[3]/tbody/tr/td”)).click();
                             or
 driver.findElement(By.xpath(“//td[contains(.,'Chapter')][1]”)).click();



    Maintenance is easy
    Debugging is easy
    Saves time and energy
    Reduces the documentation time
Advance xpath

More Related Content

What's hot

08 class and object
08   class and object08   class and object
08 class and object
dhrubo kayal
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
Kumar
 

What's hot (20)

Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, Sets
 
CS215 Lec 1 introduction
CS215 Lec 1   introductionCS215 Lec 1   introduction
CS215 Lec 1 introduction
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
08 class and object
08   class and object08   class and object
08 class and object
 
sets and maps
 sets and maps sets and maps
sets and maps
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Api presentation
Api presentationApi presentation
Api presentation
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
 
Python Advance Tutorial - Advance Functions
Python Advance Tutorial - Advance FunctionsPython Advance Tutorial - Advance Functions
Python Advance Tutorial - Advance Functions
 
Arrays
ArraysArrays
Arrays
 
STL in C++
STL in C++STL in C++
STL in C++
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
Cis166 final review c#
Cis166 final review c#Cis166 final review c#
Cis166 final review c#
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Session 16 - Collections - Sorting, Comparing Basics
Session 16 - Collections - Sorting, Comparing BasicsSession 16 - Collections - Sorting, Comparing Basics
Session 16 - Collections - Sorting, Comparing Basics
 
Export Data using R Studio
Export Data using R StudioExport Data using R Studio
Export Data using R Studio
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
Hibernate
HibernateHibernate
Hibernate
 
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7
 

Viewers also liked

Viewers also liked (13)

XPath
XPathXPath
XPath
 
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
Human Computer Interaction Chapter 4 Implementation Support and Evaluation Te...
 
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriyaInformation and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
Information and Communication Technology Chapter 1,2 ,3 - Dr.J.VijiPriya
 
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriyaIntegrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaIPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
 
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
Dr. J. VijiPriya - Information and Communication Technology Chapter 8 The Int...
 
How to create Xpath, CSS, DOM for your Selenium script
How to create Xpath, CSS, DOM  for your Selenium scriptHow to create Xpath, CSS, DOM  for your Selenium script
How to create Xpath, CSS, DOM for your Selenium script
 
Integrative Programming Technology Chapter 5 - Dr. J. VijiPriya
Integrative Programming Technology Chapter 5 - Dr. J. VijiPriyaIntegrative Programming Technology Chapter 5 - Dr. J. VijiPriya
Integrative Programming Technology Chapter 5 - Dr. J. VijiPriya
 
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriyaIPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
 
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....Human Computer Interaction Chapter 5 Universal Design and User Support -  Dr....
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 

Similar to Advance xpath

Similar to Advance xpath (20)

XML & XPath Injections
XML & XPath InjectionsXML & XPath Injections
XML & XPath Injections
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
srgoc
srgocsrgoc
srgoc
 
xpaths.pptx
xpaths.pptxxpaths.pptx
xpaths.pptx
 
streams and files
 streams and files streams and files
streams and files
 
Xml presentation
Xml presentationXml presentation
Xml presentation
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Developing web apps using Erlang-Web
Developing web apps using Erlang-WebDeveloping web apps using Erlang-Web
Developing web apps using Erlang-Web
 
Xml session
Xml sessionXml session
Xml session
 
Javascripting.pptx
Javascripting.pptxJavascripting.pptx
Javascripting.pptx
 
XPath Injection
XPath InjectionXPath Injection
XPath Injection
 
Advanced Web Programming Chapter 12
Advanced Web Programming Chapter 12Advanced Web Programming Chapter 12
Advanced Web Programming Chapter 12
 
Dax Declarative Api For Xml
Dax   Declarative Api For XmlDax   Declarative Api For Xml
Dax Declarative Api For Xml
 
Java and XML
Java and XMLJava and XML
Java and XML
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET components
 
Reitit - Clojure/North 2019
Reitit - Clojure/North 2019Reitit - Clojure/North 2019
Reitit - Clojure/North 2019
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Stax parser
Stax parserStax parser
Stax parser
 
Apache Velocity
Apache Velocity Apache Velocity
Apache Velocity
 
Os Bubna
Os BubnaOs Bubna
Os Bubna
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Advance xpath

  • 2. What is Xpath XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements is similar to the way an operating system describes paths to files XPath is almost a small programming language; it has functions and expressions XPath is a W3C standard
  • 4. Using contains to search text
  • 5. Using starts-with to search attribute value /html/body/div/table[3]/tbody/tr/td
  • 7. Using Functions //td[contains(.,'Chapter')][position() =2] //td[contains(.,'Chapter')][2]
  • 8. Axes (outline View) Starting from a given node, the self, preceding, following, ancestor, and descendant axes form a partition of all the nodes
  • 9. Axes (outline View) Self Preceding
  • 10. Axes (outline View) Following Ancestor
  • 11. Axes (outline View) Descendant
  • 12. Selecting using xpath Selecting from dropdown list driver.findElement(By.xpath("//select/option[contains(.,'pc')]")) Selecting radio button driver.findElement(By.xpath("//input[contains(@id,'red') and @type='radio']")).click(); Selecting checkbox driver.findElement(By.xpath("//input[contains(@name,'vehicle') and contains(@value,'Nothing')]")).click();
  • 13. Advantage of smart xpath processing Test case to click first chapter driver.findElement(By.xpath(“/html/body/div/table[3]/tbody/tr/td”)).click(); or driver.findElement(By.xpath(“//td[contains(.,'Chapter')][1]”)).click();  Maintenance is easy  Debugging is easy  Saves time and energy  Reduces the documentation time