UFT Pro (LeanFT) .NET SDK Reference, Version 14.03
XPathDescription Class
Example 
The description of a Web test object based on the object’s XPath.
Syntax
Example
[Test]
public void verify_CurrentDateIsPresented()
{
    // Suppose you want to verify that the AUT's home page displays today's date, but the date label does not have identification properties, and the text is dynamic.
    // You can use the label's XPath to locate it and verify that the text represents the current date.
    
    // Open the Chrome browser.
    var browser = BrowserFactory.Launch(BrowserType.Chrome);

    // Use Try/Catch to add a warning to the run report if the assert validation fails. 
    try
    {
        // Navigate to the New Tours website. 
        browser.Navigate("http://newtours.demoaut.com/");

        // Locate the label using its XPath.
        var dateLabel = browser.Describe<IWebElement>(new XPathDescription("/html/body/div/table/tbody/tr/td[2]/table/tbody/tr[4]/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td[3]/form/table/tbody/tr[1]/td/font/b"));

        // Convert the date into .NET object.
        var presentedDate = DateTime.Parse(dateLabel.InnerText);

        // Verify that today's date matches the date displayed.
        Assert.AreEqual(DateTime.Now.Date, presentedDate.Date);
    }
    catch (Exception e)
    // Use a ReportEvent step to add details to the results report if there is an error in the test.
    {
        Reporter.ReportEvent("verify_CurrentDateIsPresented", "Failed during validation", Status.Failed, e);
        throw;
    }
    finally
    {
        browser.Close();
    }
}
Inheritance Hierarchy

System.Object
   HP.LFT.SDK.PropertiesDescription
      HP.LFT.SDK.Web.XPathDescription

Public Constructors
 NameDescription
Public ConstructorXPathDescription ConstructorOverloaded. Initializes a new instance of the XPathDescription class.  
Top
Public Methods
 NameDescription
Public MethodCloneCreates an exact copy of the test object. (Inherited from HP.LFT.SDK.PropertiesDescription)
Public MethodToStringReturns a string that represents the current object. ToString override. The string representation of this XPathDescription object.  
Top
Public Operators
public Operator Implicit Type Conversion Implicit cast of the specified string to an XPathDescription.
Top