Forum Discussion

nedbacan's avatar
nedbacan
Frequent Contributor
2 years ago

Need to find a content text of an attribue in CSS, should I use XPATH?

Hello, can someone help me,using the example below on how to find an attribute from the page element and copy the content text to a variable?

 

The end goal is to copy the result to a spreadsheet (cvs) file. 

 

I believe you need to use the  XPATH method, I am just starting to get involve with TC, so I am not familiar with all the methods.  

 

See the screenshot of the CSS structure, I need to find the content text that is shown highlighted.

 

<div _ngcontent-swp-c132="" class="ng-star-inserted">Machine name: Device 102373</div>

<div _ngcontent-swp-c132="">Issued: 01/17/2023 5:46 PM</div>

 

 

 

 

Here is the xpath copy<div _ngcontent-swp-c132="" class="ng-star-inserted">

 

//*[@id="mat-tab-content-1-1"]/div/perfect-scrollbar/div/div[1]/div/div/visus-refractive-data[1]/div/div[1]/div[2]/div[1]

 

 

 Here is the xpath copy <div _ngcontent-swp-c132="">

 

//*[@id="mat-tab-content-1-1"]/div/perfect-scrollbar/div/div[1]/div/div/visus-refractive-data[1]/div/div[1]/div[2]/div[2]

 

 

  • Sorry nedbacan , I thought I was responding to your message but it was trevino912 !

     

    If your project is set to use XPath, then the Object Spy tool will show you the query e.g. "//a[.='< Home']"

     

    Also, if you use Keyword Testing and check the properties of the object, you will see the XPath that TC has identified.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Have you tried using the Object Spy tool, to see the properties that are exposed?

  • trevino912's avatar
    trevino912
    Occasional Contributor

    hello

    I never tried to use Object Spy tool ,

    could you tell please how to use it .

    • nedbacan's avatar
      nedbacan
      Frequent Contributor

      Yes, I have used the Object Spy, but still don't know how to use XPath to locate web page elements by their unique path (the example above) within the HTML structure of the page

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Sorry nedbacan , I thought I was responding to your message but it was trevino912 !

     

    If your project is set to use XPath, then the Object Spy tool will show you the query e.g. "//a[.='< Home']"

     

    Also, if you use Keyword Testing and check the properties of the object, you will see the XPath that TC has identified.