Forum Discussion

678's avatar
678
Regular Contributor
6 years ago

how to get the data from HTML page and use that as a string

i have a HTML page of 10 pages, i need to get the Data of only 5th page to a String 

 

 

4 Replies

  • richie's avatar
    richie
    Community Hero

    Hey 678 

     

    Could you supply a little more background and the use case?

     

    saying "I need to extract some data at page 5 of a 10 page .html file" needs a little drilling down to resolve the ambiguities!

     

    That said - I once had to extract some html which was a .json attribute so I just used the inbuilt xml parser available via the out of the box functionality.

     

    Cheers,

     

    richie

    • 678's avatar
      678
      Regular Contributor

      I am using following peice to read the complete html page but it a very long HTML page

       


      def filename = "C:/Users/ProjectReport.html"

       

      // read all the content of the file into a single string
      File fh1 = new File(filename)
      def report = fh1.getText('UTF-8')

       

      but i need the part of the page in between lines like 

       

      Tag line <TestSuite Results>  to  Tag line <end of TestSuite Results>

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi 678,

         

        As far as I understand, you want to parse some report. Is it a ReadyAPI report?

         


        678 wrote:

        Tag line <TestSuite Results>  to  Tag line <end of TestSuite Results>


        It's not an HTML tag. This makes me think that it will be much easier if you export your report to the XML format. By using a groovy script, you can easily extract the needed node from an XML file by using XPath. Please read the following article for more information:

        https://support.smartbear.com/readyapi/docs/testing/scripts/samples/nodes.html