Forum Discussion

tvklovesu's avatar
tvklovesu
Frequent Contributor
2 years ago

How to run Web test script from command

Hello,

I tried looking for this solution but not able to find exactly what I am looking for.

So far I have created test cases using Keyword mode and used some script routines within my keyword. But now I want to create a new test with only script and not in keyword. So I have this sample test in a script js file and trying to run from the command line. But its throwing the following error. But if I run the script from test complete UI then it works normally.

 

setBrowserPage("chrome")

 

function setBrowserPage(browser){
switch(browser){
case 'chrome':
Browsers.Item(btChrome).Run("https://www.google.com")
break;
case 'edge':
Browsers.Item(btEdge).Run("https://www.google.com")
break;
}
}

this is the error I am getting

C:\Users\vktangut\Projects\Vinod\myProject\Script\Unit2.js:8
Browsers.Item(btChrome).Run("https://www.mypoints.com/search-and-earn")
^

ReferenceError: Browsers is not defined
at setBrowserPage (C:\Users\vktangut\Projects\Vinod\myProject\Script\Unit2.js:8:7)
at Object.<anonymous> (C:\Users\vktangut\Projects\Vinod\myProject\Script\Unit2.js:17:1)
←[90m at Module._compile (internal/modules/cjs/loader.js:1085:14)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:950:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:790:12)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m

 

Can we not run the script alone from command line.