Highlighted
Absent Member.
Absent Member.
787 views

Using TruClient to execute javascript function embedded in the web page under test

Hi,

Please advise if it is possible to run a global javascript function that is embedded in the web page under test using 'Evaluate JavaScript'. 

For example, the web page under test has a function 'xyz' defined in the <script> tag.
I tried calling the 'xyz' function in the code argument of 'Evaluate JavaScript' and played the step, it is just saying that the javascript function 'xyz' is undefined. 

Thanks!
Jason

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

Re: Using TruClient to execute javascript function embedded in the web page under test

Hi

If for example you have an html like this :
<html>
<body>
...
<script>
function foo(){
...
}
...
</script>
</body>
</html>

Then In TruClient on IE and Firefox you should be able to execute foo in an “Evaluate JavaScrpt Code” step using this simple statement in the "Code" argument – “window.foo()”
In chromium, I am sorry to say it is currently impossible to do because of restrictions that chromium imposes on accessing the application code from the extension and vice versa .

Hope this helps

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.