How to read the HTML page source using QTP - html

How to read the HTML page source using QTP
Tried with the following code, which doesn't display the complete source,
browser("micClass:=Browser").page("micClass:=Page").Object.documentElement.innerHtml

When I tried it I got the correct HTML (not including the html tag, you can get that by using outerHTML instead of innerHTML).
It could be that your seeing a different result than you're expecting because you're expecting to see the original HTML served by the server (aka static html which can be seen by right-click => View Source) and what UFT shows you is the HTML rendered in the browser (aka dynamic HTML). You can read about the differences between static and dynamic HTML here.

Related

How to show rendered template as raw source code block?

I want to provide a rendered HTML block that shows an email signature - what it looks like with user data from the context - and also displays the populated HTML code as raw src to be copied for pasting into customers email signature. What would be the best (dry) way to do this?
I have tried render_to_string as a variable in the context but the HTML is rendered.
I solved this by following this answer:
How do I perform HTML decoding/encoding using Python/Django?
The rendered django template HTML needs to be decoded before it can be shown in the pre tag otherwise it will be marked up by the browser.

CKEditor SetData() is showing Raw HTML

I am currently using ckeditor in my Django project.
setData() in inserting the text as raw html content. Any suggestion how to convert that raw HTML to rich text when setData() us used.
Follwing command is used by me.
CKEDITOR.instances.editor1.setData( "<%- data.description %>" );
Met similar problem in Flask project. In my case, raw HTML tags were transfer to HTML entities, for example, "< p >" is transfer to "&ltp&gt", thus the setData did not consider them as HTML tags.
I think you should check the source code of your web page, and to see what is in the setData().
For Flask, the following answer solved my problem:
Passing HTML to template using Flask/Jinja2

How can I get FULL html code via Webkit.net

The website use ajax to load some data.When DocumentCompleted,I only get the html code without ajax data.
How to get the ajax data through webkit.net?
Thanks.
I've just recently fought with this myself and have what should be a working solution. I've not tried it with ajax, but I have used it after creating and appending DOM elements from C# and it produces the full code where DocumentText only produces the original unmodified HTML.
var fullHTML = webKitBrowser1.StringByEvaluatingJavaScriptFromString("document.getElementsByTagName('html')[0].outerHTML")
The only limitation to this method that I've seen is that it does not include the doctype tag if there is one, but everything else is there.

How to show XSL-converted XML as a part of an HTML page?

Can I embed an XML file in HTML without using iFrames?
I want to show XSL-transformed XML(which, is HTML as a result of transformation) as a part of my HTML document. Hope this makes it clearer.
If my description of problem is unclear, please tell me and I will try to explain it more.
You can easily use browser based XSL transformation routines to convert an XML string into an XMLDocument or HTML output that can then be applied into any page element.
The steps could be briefly summarized as:
Load an XML string from a resource (or as the result of an AJAX hit).
Load the XML document into an Xml document object (code differs for Browsers - IE uses the ActiveXObject MSXML - DOMDocument, while Mozilla uses the built-in implementation to create a Document. Chrome on the other hand uses the built-in XmlHttpRequest object as the only available XML document object.)
Load the XSL document similarly and set its arguments.
Transform the XML and obtain output as a string.
Apply the string output to any page element.
Note that the code differs for each browser so it may be simpler to use a public JS framework such as JQuery or Prototype.
You will need to use html entities. For example this is how you would write a name tag
<name>.
More reading here

Working with Javascript and images in AIR's HTML component

I'm having the following problems using Javascript and img tags in the standard HTML component in AIR:
1- Javascript in the xml literal causes problems (even though it shows using them here: http://livedocs.adobe.com/flex/3/html/ProgrammingHTMLAndJavaScript_07.html#1032824
2- Using html.loadString(...<img src="/tmp/me.jpg" />...) does not show the image.
3- After wrapping the Javascript in CDATA tags it is still not accessible and returns an 'invalid function' error when trying to reach it.
The second 2 issues seem to go away if I save the html to a file and load it with html.load(file) instead of trying to read it as a string. Any suggestions to solve these issues?
I ended up saving the file to a temporary file and using html.load(tempfile).