How to select this title from xpath

287 views
Skip to first unread message

Sangam Sood

unread,
Jun 17, 2019, 9:06:58 AM6/17/19
to Selenium Users
Hi i want to get "Total of 23 record(s) in 2 page(s) " this msg as output

<a href="#pageshow" data-action="page-show" rel="tooltip" data-placement="bottom" data-original-title="Total of 23 record(s) in 2 page(s)" class="btn btn-default txt-color-blue dropdown-toggle" data-toggle="dropdown" xpath="1" style="">1<i class="fa fa-sort-desc pull-right"></i></a>

This is the xpath from which i want to select text

i tried --
System.out.println(driver
.findElement(By.xpath("/html[1]/body[1]/div[6]/div[1]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/a[2]"))
.getAttribute("value"));
but get null as output

Jagu Lakshmi Pavani

unread,
Jun 17, 2019, 9:51:24 AM6/17/19
to seleniu...@googlegroups.com
HI,
  Please use this xpath
//a[@data-original-title=''Total of 23 record(s) in 2 page(s)']

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/81b34b3d-2000-4930-a2cc-7d0444a809f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Lakshmi Pavani Jagu,
+56 961133614,
jlpav...@gmail.com

Jayshree Braley

unread,
Jun 17, 2019, 10:39:43 AM6/17/19
to seleniu...@googlegroups.com
Use getTitle() method or getText()

John Doe

unread,
Jun 18, 2019, 5:20:18 AM6/18/19
to Selenium Users
You need to get data-original-title attribute, not value, something like:

System.out.println(driver.findElement(By.xpath("/html[1]/body[1]/div[6]/div[1]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/a[2]")).getAttribute("data-original-title"));

Normally you should not use absolute XPath locators as they might be very fragile/sensitive to any markup changes, maybe you could simplify the XPath expression to be shorter like:

//a[@href='#pageshow']

there is also xpath attribute which you potentially could use like:

//a[@xpath='1']

More information:

Reply all
Reply to author
Forward
0 new messages