Forum Discussion

Egg's avatar
Egg
Frequent Contributor
4 years ago

I want to save the web page's text using keyword test.

Hello,

Can I save web page's any text to Test complete's variable using Keyword test ? 

How can I do that?

 

Finally, I wanna receive text on the web page. and compare my text with received text on the web page. 

and then put out log messege. 

  • Lee_M's avatar
    Lee_M
    Community Hero

    Egg, what do you mean by any text - are you talking about webpages?

     

    Is this a component called 'any text' or a specific component defined at runtime or ALL text on the page?

     

    One approach to this issue would be accessing the DOM the NativeWebObject or the contentDocument these give you cirect access to the page DOM which can then be manipulated with regex

    - Scripting (code snippet) only

     

    e.g. (untested codes)

    pagetext = Sys.Browser().Page("*").contentDocument.textContent

    allDOM = Sys.Browser().Page("*").contentDocument.all

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Alternatively to what was suggested by Lee_M, you may consider to use .text/.wText/.value property of page object. (Check using Object Browser what property exists and contains plain page text.)

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Great advice, Community!

       

      Egg which suggestion did you end up using?