Creating first script in TestComplete

We've created TestComplete first project in previous post and lets create first script. Before that we can have an idea about scripting languages supported in TestComplete. Following languages are supported in TestComplete
  1. JavaScript
  2. JScript
  3. Python
  4. VBScript
  5. DelphiScript
  6. C#Script
  7. C++Script
In this tutorial, we've selected JavaScript, since it is very simple and easy to understand.

Hope you all created the project as per the previous postOkay.. Now we can automate a simple task in TestComplete using JavaScript

Task details
1. Launch web browser
2. Navigate to test url
3. Ensure that page has been loaded successfully, here is the code. Copy below code snippet the script work space and click on green run button.
function Main() {
Browsers.Item("firefox").Run("https://www.goole.com");
page=Sys.Browser("firefox").Page("https://www.goole.com");
page.wait();

if(page.exists)
 {
   Log.Message("URL has been successfully loaded")
 }
else
 {
   Log.Message("Failed to load the URL")
 }
}
You can see that Firefox browser get launched and navigated to google url mentioned in that code. If the page has been successfully loaded then page.exists should be 1. This condition has been considered the if clause. You can see that execution log in project pane
أحدث أقدم