Skip to content

Exec JavaScript

gcvfi edited this page Mar 4, 2020 · 3 revisions

Back to AIQ Commands | Home


Note: Draft content, work in progress, not yet reviewed or verified.


Statement

Example

Test Case

Test Steps Data
open website https://www.google.com/
save text as js_alert alert("Hello World");
save text as js_statment1 return "Hello World 1";
save text as js_statment2 return aiq_1 + ' ' + aiq_2
save text as js_fname John
save text as js_lname Smith
save _js{return "Hello" + " " + "World";} as js_result01
call _js{alert( "Hello" + " " + "World");}
Switch to alert and click on ok
Exec _js{alert( "Hello" + " " + "World");}
Switch to alert and click on ok
Exec _js{return Math.random().toString(36).substring(6);} returning ${js_result02}
Exec _js{return aiq_1 + ' ' + aiq_2;} with ${js_fname}, ${js_lname} returning ${js_result03}
exec script _js ${js_alert}
Switch to alert and click on ok
exec script _js ${js_statment1} returning ${js_result11}
exec script _js ${js_statment2} with ${js_fname}, ${js_lname}
exec script _js ${js_statment2} with ${js_fname}, ${js_lname} returning ${js_result21}
begin script _js
var msg1 = "Hello"
var msg2 = "World"
var msg = msg1 + " " + msg2
return msg;
End script save as ${js_result21}
begin _js with ${js_fname}, ${js_lname}
return aiq_1 + ' ' + aiq_2;
End script save as ${js_result22}
exec "example1.js"
exec "example1.js" returning ${js_result31}
exec "example2.js" with ${js_fname}, ${js_lname}
exec "example2.js" with ${js_fname}, ${js_lname} returning ${js_result32}
wait 1 sec

Artifact

example1.js

var msg = "Hello World";
return msg

example2.js

var first_name = aiq_1;
var last_name = aiq_2;

var fullname = first_name + " " + last_name;
return fullname;

See also

Clone this wiki locally