Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:46:08+00:00 2026-06-15T10:46:08+00:00

I have xpath written in Selenium RC & now I want to write the

  • 0

I have xpath written in Selenium RC & now I want to write the same xpath in selenium Webdriver. below is the xpath:

"//table[@id='lgnLogin']/tbody/tr/td/table/tbody/tr[4]/td"

by using this xpath, i am capturing the error message displayed on my application like “Please check your Password”.

Now how can I write it in Webdriver. I have different ways but, not worked out.

"String msg= driver.findElement(By.xpath("//*[@td='error2']")).toString();" – This is what i did in Webdriver.

Please help me out on this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:46:09+00:00Added an answer on June 15, 2026 at 10:46 am

    The XPath hadn’t change from Selenium RC to WebDriver.

    If you were able to use the some XPath-expression before it should work in WebDriver too (in 99% of cases as usual).

    The code below should work but it’s pretty hard to answer without seeing your HTML.

    String msg= driver.findElement(By.xpath("//table[@id='lgnLogin']/tbody/tr/td/table/tbody/tr[4]/td")).getText();
    

    //*[@td='error2'] – this expression looks bad as it means “any element with attribute named “td” and value “error2”. I suppose that you don’t have ‘td’ attributes in your HTML.

    And to the end. I wouldn’t recommend to use such long XPath expressions as in your example. It might be broken due to any minor change in layout. It’s better to use some specific attributes rather than long hierarchy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I have the following XPATH line: //det[@nItem=1]/prod/cProd That successfully selects the desired node using
I have the below xpath expression //div[@class=post-content]//img which runs on a html page, scanning
I have written a small function, which uses ElementTree and xpath to extract the
Currently, I'm adding elements to my XmlDocument using XPath notation for which I've written
I have been using Selenium a lot lately (testing an ExtJs app) and while
I need to get the xpath of current node for which i have written
I have this xpath: //*[@id=someId::button] Pressing it shows a dropdown list of values. Now,
Im using Capybara & I am trying to find some xpath that may or
I have a Xpath query which accepts array elements for output using Axslx, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.