How to execute Javascript via code

Ask general questions here.
Sundaytwins
Posts: 14
Joined: Thu Nov 02, 2017 2:55 pm

How to execute Javascript via code

Post by Sundaytwins » Wed Dec 06, 2017 11:36 am

Hi,

I'm currently testing a web application in which there is an impossibility to test a certain functionality by just 'clicking' it.
Therefor, the solution that can help is to execute the JS behind the button.

Now I'm struggling to have the JS executed.

When i first tried with:

webdocument webDoc = "/dom[@domain='ourdomain']";
webDoc.ExecuteScript("BcsCommon.app.blabla.instance.scripttoExecute(['Argument'])");

Ranorex replied :
The type or namespace name 'webdocument' could not be found (are you missing a using directive or an assembly reference?) (CS0246)

Elsewhere i found that i needed the 'Microsoft Internet controls' reference.
I tried to add it, but now the error reads:

Task failed because "AxImp.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "AxImp.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK. 2) Install Visual Studio 2010. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the "ToolPath" parameter of the task. (MSB3091)

Can anyone help please? I'm unable to install software to the machine as i'm not local admin for it.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to execute Javascript via code

Post by odklizec » Wed Dec 06, 2017 12:29 pm

Hi,

In my opinion (and the errors you are getting support this opinion), there are not installed all required libs? Typically, Ranorex installs all required/missing libs during the setup. Just in case, go to this page and examine the list of required software and make sure all of them are installed on your system...
https://www.ranorex.com/help/latest/system-requirements
I'm afraid, if you don't have rights to install things onto the computer in question, you will have to ask someone to do this for you or ask someone to grant you with required rights.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Sundaytwins
Posts: 14
Joined: Thu Nov 02, 2017 2:55 pm

Re: How to execute Javascript via code

Post by Sundaytwins » Wed Dec 06, 2017 1:11 pm

Hi,

Thanks for your quick reply. I checked all packages and they are available on my computer.
I recently updated my PC to Ranorex version 7.2 (which took me almost two weeks to get the necessary rights to do it).
That's why I wrote that i don't have access to install stuff. (it just takes ages and i need a pretty good reason to do so)

I guess, all required packages were installed from the installation/update i performed.

Still, the problem remains....

Sundaytwins
Posts: 14
Joined: Thu Nov 02, 2017 2:55 pm

Re: How to execute Javascript via code

Post by Sundaytwins » Wed Dec 06, 2017 3:11 pm

Hi,

Found the reference problem and it occurs to be a typo...

No reference errors anymore, but js is not running yet.
We'll keep trying.

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: How to execute Javascript via code

Post by Vaughan.Douglas » Thu Dec 07, 2017 1:16 pm

Sundaytwins wrote:Hi,

Found the reference problem and it occurs to be a typo...

No reference errors anymore, but js is not running yet.
We'll keep trying.
Just for clarification, you're not getting ANY errors anymore? It's now a case of nothing happens?
Doug Vaughan