Ask a Question

Migration Jscript to JavaScript and contentDocument.Script

SOLVED
stm
Occasional Contributor

Migration Jscript to JavaScript and contentDocument.Script

Hi,
I'am trying to migrate an existing Project from Jscript to Javascript and I've read the instructions for migration
https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript-for-jscript-users.htm....

Migration self works fine except one strange problem with Internet-Explorer:
The testscript calls custom javascript with page.contentDocument.Script, this works in Chrome and Firefox
In Internet-Explorer I get an error with TypeError: Cannot read property <Javascript-Funktion-Name> of undefined

In Jscript the function call works without any problem. What can be wrong?
Before posting I'v tried several things without sucess.

greetings
Martin Stromberger

5 REPLIES 5
tristaanogre
Esteemed Contributor

It would be helpful to see the actual code that you are attempting to execute.  That will help us debug better.

In the meantime, in your conversion, take a look at https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript-for-jscript-users.htm... There may be additional things you need to change in order for your code to work.


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
stm
Occasional Contributor

Hi,

thanks for the quick response - following code is executed:

The PageObject is fetched this way (browser and url are variables)
page = Sys.Browser(browser).Page(url);

The custom javascript call
pageready = page.contentDocument.Script.$.cs.canChangePage();

The bold marked text is the custom function. I am not shure if it matters, at debugging I found out
that firefox and chrome have a contentDocument.Script, Internet-Explorer has no Script.

greetings
Martin Stromberger



 

stm
Occasional Contributor

Hi,

well I've spend about 4 hour in debug and try to get the code running for Internet-Explorer. I've read and checked
https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript-for-jscript-users.htm...
https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript.html
https://support.smartbear.com/testcomplete/docs/reference/language/javascript/get-method.html

The result is still the same. I've a backup of the old project and I'm thinking to step back to Jscript.
Is there anything else I could try?

greetings
Martin Stromberger

tristaanogre
Esteemed Contributor

In Internet Explorer, it's contentDocument.scripts instead of contentDocument.Script  So, you'll need to add conditional logic to your test case to detect what browser so it will execute appropriately.


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
stm
Occasional Contributor

Hi,

after reading this page https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html once again I found the solution. The importand part in the lineked page is "Executing Application-Defined Script Functions"
I've addet the eval an then it worked in Internet-Explorer (and still in Chrome and Firefox)

greetings

Martin Stromberger

cancel
Showing results for 
Search instead for 
Did you mean: