Reflection Desktop VBA Guide
Attachmate.Reflection.Objects Library / Attachmate.Reflection.Objects.Web.Msie Library / WebElement Object / GetElement Method
An XPath path pointing to a WebElement in the WebDocument. XPath is a language that describes how to locate specific elements in XML documents by using an addressing syntax, based on a path through the document's logical structure or hierarchy. A sample XPath syntax: HTML/BODY/TABLE/TBODY/TR[1]/TD[1], where WebElement index starts from 0.
Example
In This Topic
    GetElement Method (WebElement)
    In This Topic
    Gets the first Web element by an XPath path, relative to the current Web element.
    Syntax
    expression.GetElement( _
       ByVal xPath As String _
    ) As WebElement object 
    where expression is a variable that represents a WebElement Object

    Parameters

    xPath
    An XPath path pointing to a WebElement in the WebDocument. XPath is a language that describes how to locate specific elements in XML documents by using an addressing syntax, based on a path through the document's logical structure or hierarchy. A sample XPath syntax: HTML/BODY/TABLE/TBODY/TR[1]/TD[1], where WebElement index starts from 0.

    Return Value

    A WebElement object, or Nothing if no WebElement is found.
    Example
    This example navigates to a Web page and clicks on a link in the page. To run this sample, create and open a Web session and run this code in the session code module.
    Sub webClick()
        
        'Declare variables: 
        Dim wControl As Attachmate_Reflection_Objects.WebControl
        Dim wDocument As WebDocument
        Dim wElement As WebElement
        Dim wElementInput As WebElement   
     
        Set wControl = ThisWebControl
        
        'Get a handle to the workspace
        Set app = GetObject("Reflection Workspace")
     
        'Go to the Host Access Analyzer documentation page
        wControl.Navigate1 ("https://www.microfocus.com/documentation/host-access-analyzer/")
                
        'Wait until the Web page is ready and then set it as the Web document
        Do Until wControl.ReadyState = WebBrowserReadyState_Complete
          app.Wait (1000)
        Loop
        
        Set wDocument = wControl.Document
        
        'Get the table that includes the link
        Set wElement = wDocument.GetElementById("getting_started")
        
        'Get the link element
        Set wElementInput = wElement.GetElement("tbody/tr[0]/td[0]/a[0]")
     
        
        'Click the link
        wElementInput.Click
        
        'Print the tag name of the element
        Debug.Print wElementInput.tagName
        
    End Sub
    See Also