Monday May 12, 2008

XPath: Matching a node element having a specific text

 

 

Problem : To identify uniquely a GUI element having a text "Enterprise Sample" within its <a> tag

Solution : The page source of the web page shows the element as  <a href="clickme.html">Enterprise Sample</a> . Use the below command in xpath checker to uniquely identify this element

 //a[contains(text(),"Enterprise")]

In layman's term, the above command will look 

  1. first for all occurrence of <a> tag within the web page
  2. then matches the value of <a> tag with user's text (here "Enterprise")

 

 

 

About

I'm a Quality Engineer at Sun Microsystems. Here in this blog, you may find information about Software Testing, Portal Server, Virtualization, Web2.0 and Misc Technical topics. The views expressed here are personal and does not reflect that of my employer

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today