Ask a Question

inner html

bistritapcv
Contributor

inner html

I am running a desktop operation, and it brings up an IE window.  So I would like to get text from the IE window.  I cannot do an inspect (F12) on it so I don't know all the fields, but I know for sure there is an html.  So I did a

 

var browser = Connect.Sys["Process"]("iexplore", 900000);
var html = browser["FindChildByXpath"](".//html");

 

I am not sure what to do to get the text.  These both compile and run, but they are either "var" object or "com" object.

Now that I (apparently) have the innerhtml, how do I get the text from it?

 

And to repeat this is a desktop test, which spawns an IE

  • IE
6 REPLIES 6
tristaanogre
Esteemed Contributor

First, in order for TestComplete to interact with web pages, even ones embedded in desktop apps, you need a web license.

 

Assuming, first, you have that...  You can use Connect.Sys.Browser('iexplore').<page object>.innerText


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

I am sure we have a web license.

I don't really know what the <page object> will be.

But the url has "random=0.3334441223159447" or some other random number in it, so there is no way I would know what the URL is.  The page is already being displayed too, so I don't want to start a new session.

You should be able to, in your code, replace any dynamic/random values in the URL with the asterisk character to wildcard it.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
TanyaYatskovska
SmartBear Alumni (Retired)

HI @bistritapcv,

Did Tristaanogre's suggestion help?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



ishan_07
Occasional Contributor

Hello,
You will get the HTML of the selected selector and you can also print on web page or in  log. Following is the HTML code for innerHTML.

E.g.

var x = document.getElementById("myP").innerHTML;

 

> HTML of the selected selector

TestComplete is not Selenium.

While in general, your code might work in TestComplete as well, the case is how to get the reference to the document property in this given case.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: