Categories

File selection by browsers

Why select files from a browser?

When performing business scenarios involving web solutions, there is a case that occurs frequently: the interactions with the operating system, and in particular the selection of files to download them to the web server ( we are talking about upload).

This feature is indeed implemented by all tools managing business data: ERP, GED, PLM, CRM ...

The upload function is implemented natively in all browsers because they must respect the HTTP standard that specifies how this file transfer takes place.

All browsers have therefore implemented a file selection menu on the computer or on a network access, and then transmit it to the server. This usually involves using a modal file selection window whose implementation depends on the desktop environment, but each browser can have its own implementation.

Problems caused in test automation

This causes two types of problems while automating this procedure in a test

  • Issue 1: The test software must be able to interface with the "desktop" part of the browser. In this case, to rely on the HTML page and the DOM is not enough, it is necessary either to recover and to recognize the internal structure of the components and controls of the navigators, or to use the graphic recognition ...
  • Issue 2: The "file selection" can vary greatly from one browser to another, which requires adaptations depending on the browser used.

Solution to problem 1: Agilitest is a multi-channel solution

Agilitest is an integrated test solution that supports the use of different application technologies (web, desktop, ...) within the same test. We will use a DOM-desktop failover.

The issue 1 is easily handled by Agilitest and here is the solution:

  • Open a channel on your application and run your test up to the download part.
  • When the file selection popup opens, simply press the "ALT" key on your keyboard to switch from the DOM component recognition mode to the desktop component recognition mode. There, you will be able to navigate in your window of selection of the file.
  • At the end of the selection of your file, you can close the modal window and use the "ALT" key to switch back to the web part with a DOM.
Selecting a file on the user's computer from a web application

Tip: For more robustness, we advise you to set a file in an easily accessible tree of your filesystem and that you can reproduce everywhere, for example in "quick access" under Windows Explorer.

Solution to Problem 2: Agilitest knows how to handle the specific behavior of browsers

Issue 2 is managed with Agilitest using sub-scripts set up via a data-driven testing (CSV) data file in the following combination:

  • Calls of a first sub-script fed by the parameter "navigator" in column of the file CSV. We recover the name of the browser to iterate the launch of the same test on several browsers.
  • Calling subsequent sub-scripts whose name is composed from the "browser" parameter of the first sub-script. For example: script_chrome.ats, script_opera.ats, etc. We use the name of the browser to customize the name of the executed script.

The proposed solution makes it possible to manage the differences of behavior of browsers. However, we do not recommend that you use it for the following operations, which are handled directly by Agilitest for all browsers:

  • Navigate to a URL, prev, next, home ...
  • Closing the window
  • Tab change

This would make your tests non-generic, which is not desirable.

Still require support?
Contact support