+91-08122241286 , 9003085882 thecreatingexperts@gmail.com

Selenium automation Testing – Types of XPATH

The Creating Experts SELENIUM, Selenium Training in Chennai, TESTING Training Selenium automation Testing – Types of XPATH
Selenium automation Testing – Types of XPATH

SELENIUM Selenium Training in Chennai TESTING Training

Selenium automation Testing – Types of XPATH

Posted By Admin Creating Experts

Types of xpath

1. Absoulte : xpath starts with single / or starting from Html tag.
2. Relative : xpath starts from // 

Absolute

/html/h1/h2/bodyinput/div = login id
/html/h1/h2/body/div/div = password
/html/h1/h2/body/div/div/a = login

//div[1]

Relative:

//div[@id='uname']  or //*[@id='uname'] 
//div[@id='pass']
//a[@id='signin']

Reference: http://www.w3schools.com/default.asp

eclipse - site.

launch URL
http://docs.seleniumhq.org/download/
textbox
input id="q"
name="q"

go button
input id="submit" t

//input/a[1]

xpath a@id=test
css   a#test

xpath a@class=new
css   a.new

css a[name='q']
nth=child(1)

//font/a

//font[@id ='addlang']/a

Refer:

http://docs.seleniumhq.org
http://www.w3schools.com/
1. Xpath
2. Html

Base sample given(Below content can be see in the mail sent)
<html>
<h1>  </h1>
<h2>  </h2>
<body>
<input>
<div id=uname Login Id >
<div id=pass password  >
<a id=signin Login     >
</body>
</html>

Types of xpath
1. Absoulte : xpath starts with single / or starting from Html tag.
2. Relative : xpath starts from //

Absolute
/html/h1/h2/bodyinput/div = login id
/html/h1/h2/body/div/div = password
/html/h1/h2/body/div/div/a = login

My comments:
============

1. The xpath  to find "uname" should not include h1/h2 to identify
login id. We need not include same level element.Only hierachial
element should be used to identify xpath.
          The actual xpath should be /html/body/div

2. The xpath to find element "pass" should not include "h1/h2" and
also "div" at the same level will be returned as array so it should
not be div/div.

when it is <div/>
           <div/>
            The xpath should be /html/body/div[2] to access second
element in div.

When it is like div within a div then only the xpath mentioned during
session is correct.
<div>
   <div/>
</div>
   For this only the xpath should be /div/div

Tagged ,

Written by Admin Creating Experts

The Mobile Apps Development company and Creating Experts in Advanced Technologies.

http://www.thecreatingexperts.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Register in our Elearning Tool and Get the real time Training from our Experts-Grasso Tool

Register Now

Copy Rights Powered By: Creating Experts 2016.