Table of contents
1.
Introduction
2.
Opening Dynamic URLs in the Browser
2.1.
Environment-specific URLs
2.2.
URL at Run Time
2.3.
Parametrizing the URL
3.
Uploading Files 
3.1.
Command to Upload File with Element
3.2.
Command to Upload File with Windows Explorer
4.
Frequently Asked Questions
4.1.
I ran the upload file command, so why couldn't I see any File Explorer windows being opened?
4.2.
How will I provide the value of Run Properties if I am using ACCELQ CLI?
4.3.
What should be preferred - Absolute Paths or Relative Paths?
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

Uploading File and Opening URLs in Browser in ACCELQ

Author Satvik Gupta
1 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

ACCELQ is a platform for automated testing. It provides tools for testing APIs, databases, and mobile and web apps. We can add multiple tests with intricate testing. We can coordinate and work with the other members of our team.

 

Uploading File and Opening URLs in Browser in ACCELQ

This blog will look at opening dynamic URLs (at runtime, from environment variables, etc.) and uploading files while performing tests in ACCELQ.

Opening Dynamic URLs in the Browser

Opening a URL in a browser using ACCELQ is very straightforward. We just provide the URL to be opened in the Initialize step. This step is available for all entry-point Contexts. But what if we want to open a dynamic URL, i.e., a URL whose value we do not know or which may vary? 

Fortunately, ACCELQ has support for this as well. Let's see the various ways to open dynamic URLs in ACCELQ.

Environment-specific URLs

Sometimes, we may have different URLs for different environments.

For example, URLs of different environments may be

  1. Production - live.codingninjas.org
     
  2. Staging - staging.codingninjas.org
     
  3. Testing - test.codingininjas.org
     
  4. Development - dev.codingninjas.org
     

We can provide environment-specific URLs by simply referencing a Global Property in the Initialize step (which is the step in which we provide the URL).

Global Properties in ACCELQ are properties, or fields, that are applicable all across the project. These can contain values such as application URL, port number, API keys, etc. 

We can configure them to have different values in different environments. 

To pass an environment-specific URL,

  1. Define a new Global Property in the Resources section of ACCELQ. Click on the Radio button that says, "Each Application Environment may have a different value." Specify appropriate values for each environment. 
     
  2. In the side-bar for the context (that we are adding this URL to), click the entry point URL. Set the left drop-down as Global Property and the right drop-down to point to the URL global property that you just created.
     
  3. If only specific scenarios need the Global Property, we can click on the initialize step of the Scenario and perform the same steps.

URL at Run Time

If we cannot hardcode the URL before runtime, we can override the URL in the Initialize step with a Run Property. Run Properties are properties whose definitions we provide in the Resources section. We only define the specification. The value is provided at run time. Whenever an action encounters a property defined as a Run Property, ACCELQ will show you a prompt where you can enter it. 

To pass a URL at Run Time, we can override the URL in the Initialize step with a Run Property.

Parametrizing the URL

Sometimes, the URL can be completely dynamic - and based on your code's logic. We can meet this requirement by creating a new Action that: 

  1. Has the necessary parameters, such as server name, port number, etc.
     
  2. Contains the logic to create the final URL. 
     

After the logic to create the final URL, we can add the command to the Action. Then we simply provide it with the URL we have calculated. The command syntax is: 

Load the browser with URL: <url>

Where <url> contains the URL we have calculated. 

This newly created Action should be added right after the Initialize step in the Scenario. The URL provided in the Initialize Step will be overwritten by the one we create in this Action.

Uploading Files 

A very common feature in websites is uploading a file. When we click a file upload button, a window pops up - the native file explorer of our OS. It will be Explorer on Windows, Finder on Mac, etc. Let us see how to perform file upload operation in ACCELQ. 

Command to Upload File with Element

The command for the same is Upload File with Element. It is written as

Upload a file <File Name> by clicking on the Element <File Element>

 

<File Name> should contain the path to the file we want to upload. This can be an absolute path from the Local Agent Machine or a relative path. If it is a relative path, it must be relative to the Agent's installation folder. (i.e., the path where ACCELQ Agent is installed on the system)

<File Element> should contain the element clicked on the browser screen to open the file explorer. Normally, this will be of the type

<input type ="file">

 

Generally, file upload buttons and file upload areas are used. ACCELQ supports both of them. Sometimes, the button or area may not be visible or accessible when the test is being performed. ACCELQ will search through the hierarchy of whatever element it is given and find the correct element that it can use to upload the file. So, we can provide any visible element with the File Upload element in its hierarchy, and ACCELQ will handle the rest.

Command to Upload File with Windows Explorer

This command is available only on Windows systems. It is written as: 

Click on <File Element> 
Upload a File <File Name> using Windows Explorer

 

Where <File Element> and <File Name> are the same as defined above. 

Frequently Asked Questions

I ran the upload file command, so why couldn't I see any File Explorer windows being opened?

The File Explorer windows are not physically displayed. ACCELQ uploads our file automatically by using send-keys on the input field. This makes our command portable and allows it to run on different OSes.

How will I provide the value of Run Properties if I am using ACCELQ CLI?

In GUI, a prompt is shown in which we can provide the value of the Run Property. In CLI also, ACCELQ will stop the execution and display a prompt on the CLI, asking for the value of the run property. Execution will halt until the value is provided.

What should be preferred - Absolute Paths or Relative Paths?

It is up to you, but Relative paths offer flexibility. This is because different OSes have different structures for file paths. By using relative paths, we can ensure that all Agents that are running that test have a common path - since it will be relative to the install location.

Conclusion

This blog has explored what ACCELQ is and how we can open dynamic URLs and upload files in ACCELQ. We have seen how we can open dynamic URLs by environment variables, run-time, and parametrizing. We have seen different ways to upload files as well.

We hope you leave this article with a broader knowledge of ACCELQ, automation, and testing. We recommend that you explore our different articles on these topics as well, such as:

What is ACCELQ?

Running Manual Tests in ACCELQ.

What is context and its creation in ACCELQ?
 

You can practice questions on various problems on Coding Ninjas Studio, attempt mock tests. You can also go through interview experiences, interview bundle, go along guided paths for preparations, and a lot more!

Keep coding, keep reading Ninjas. 

Live masterclass