ExecuteScript to Variables

Class library usage, coding and language questions.
Lyuba Boerma
Posts: 36
Joined: Mon Apr 01, 2019 12:12 pm

ExecuteScript to Variables

Post by Lyuba Boerma » Thu Apr 11, 2019 2:57 pm

Hello)
for my project i need to make a test which simulated Scanning bar-codes .
i need to do a lot of same actions to different items
So my question is....can i convert script value to a variable?

Everything what is inside ( ) make a variable

Code: Select all

repo.Dom.Self.ExecuteScript("BarcodeListener.applyBarcode('Blablabla')");
Delay.Milliseconds(1000);
for example

Code: Select all

repo.Dom.Self.ExecuteScript(varBarcodeActions);
Delay.Milliseconds(1000);

Is it possible??

Thanks for help
You do not have the required permissions to view the files attached to this post.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: ExecuteScript to Variables

Post by Stub » Fri Apr 12, 2019 7:58 am

You can easily call onto other code from a Code Module. While I have no idea how your code is structured:

Code: Select all

BarcodeListener listener = new BarcodeListener (repo.someItemInfo);
listener.applyBarcode("Blah Blah");
But that probably misses your point since I'm not familiar with this ExecuteScript API.

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

Re: ExecuteScript to Variables

Post by odklizec » Fri Apr 12, 2019 8:58 am

Hi,

Since the RunExecute script is basically a simple string, you can, of course, use variable as ExecuteScript parameter. If you want to use it in code, you can do it as you suggested in your initial post. You just have to use it in UserCode of selected recording or custom created code module.
ExecuteScriptVar.png
You do not have the required permissions to view the files attached to this post.
Last edited by odklizec on Fri Apr 12, 2019 2:22 pm, edited 1 time in total.
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

Lyuba Boerma
Posts: 36
Joined: Mon Apr 01, 2019 12:12 pm

Re: ExecuteScript to Variables

Post by Lyuba Boerma » Fri Apr 12, 2019 2:15 pm

Thank you! It is working!))
I Made it with variables, as you showed :D

Unmeshatodkar
Posts: 1
Joined: Mon Apr 29, 2019 7:03 am
Contact:

Re: ExecuteScript to Variables

Post by Unmeshatodkar » Mon Apr 29, 2019 7:05 am

Thanks odklizec, It was valuable answer for me also. Great help!