Embedded frameworks / headless browsers

This topic describes how to get started with testing Web apps in embedded frameworks, or when testing headless browsers.

For details on testing web apps in an Internet Explorer embedded browser control, see Internet Explorer embedded browser controls.

Supported frameworks / Headless browsers

UFT can record and run tests using standard GUI testing support on Web apps developed with the following frameworks and Headless browsers:

Chromium-based frameworks

  • Chromium Embedded Framework (CEF). Chromium Embedded Framework support is applicable for Java CEF, CEF Sharp, and Adobe CEP. CEF in this topic refers to all of the above.

  • Electron

  • JxBrowser

  • NW.js

Headless browsers

  • Headless Chrome

  • PhantomJS

These advanced frameworks and browsers are not supported for other Web-based add-ins, such as .NET Web Forms, Web-based SAP, Siebel, and Java.

The advanced frameworks and browsers are supported in Web extensibility-based add-ins, such as the Web 2.0 Toolkits.

Caution: The instructions in this topic include downloading executable files from the Internet, such as chromedriver.exe and phantomjs.exe, which are not provided by Micro Focus.

We encourage you to use only genuine executable files from the official Chrome, NW.js, and PhantomJS Internet sites. Failing to comply with this recommendation may expose your system to increased security risks. Any and all associated risks are the Customer's responsibility and Micro Focus will not be held accountable for the same.

Back to top

Connect to your Web app

Before recording or running your test, do the following:

Prepare your application for testing

Configure your embedded browser to always open a port for remote debugging.

Check your embedded browser's documentation for instructions on how to do this.

Note the port number, to use in subsequent steps.

CEF example:

In the CEF folder, open a command prompt and run the following command: cefclient.exe --remote-debugging-port=<port number>

Define UFT One options

Add the remote address and remote debugging port number for your Web app in the Remote Connections pane of the Options dialog box. This enables UFT to find the application's objects when recording.

For details, see Web Remote Connections Pane (Options Dialog Box > GUI Testing Tab).

Prepare your UFT One machine

Perform additional steps on your UFT One machine when testing specific frameworks. For details, see:

Testing on a remote machine If you are running a UFT One script on a remote machine, continue with Configure connections on a remote machine before you run your test.

Programmatically connect or disconnect from your app

Add the following statements to your test or component to enable UFT One to attach or detach from the application:

  • WebUtil.AttachRemoteDebugging

    Example:

    Webutil.AttachRemoteDebugging "127.0.0.1:3056",default,"C:\downloads\chromedriver.exe"
  • WebUtil.DetachRemoteDebugging

In these statements, you provide the remote address and remote debugging port number for your Web app.

For more details, see the WebUtil object in the Utility section of the UFT One Object Model Reference for GUI Testing.

Note: UFT One cannot identify objects in your application if you have manually closed the connection to that application.

Using different ChromeDriver versions

The UFT One installation includes a ChromeDriver for testing CEF, Electron and JxBrowser applications. You can find the version of this ChromeDriver in the UFT One Product Availability Matrix.

If the Chromium-based framework you are using for your application requires a different ChromeDriver version, do one of the following:

  • In the <UFT One installation folder>\bin\WebDriver directory, replace the chromedriver.exe file with a the version that matches your application.

  • Store one or more versions of the chromedriver.exe on the UFT One computer. When calling the WebUtil.AttachRemoteDebugging method, specify the path to the relevant chromedriver.exe.

For more details, see http://chromedriver.chromium.org/downloads.

Back to top

NW.js Framework

To test Web apps that are embedded in the NW.js framework, UFT One communicates with the NW.js framework via the NW.js WebDriver.

Before testing your NW.js application, ensure that the NW.js WebDriver is present in the UFT One installation folder.

Do the following:

  1. Browse to https://nwjs.io/, and download the SDK, which includes the chromedriver.exe file.
  2. Copy the chromedriver.exe file to the <UFT One installation folder>\bin\WebDriver\NW directory.

You can use different versions of the NW.js WebDriver for different applications. Store the chromedriver.exe file in different locations, and provide the path to the relevant WebDriver in the call to WebUtil.AttachRemoteDebugging.

Back to top

Configure connections on a remote machine

If you are using a Chromium-based framework and running a UFT One script on a remote machine, additionally configure the remote machine as follows:

  1. Install socat from one of the following locations:

    Mac: http://www.dest-unreach.org/socat/download/

    Windows: https://github.com/tech128/socat-1.7.3.0-windows

  2. Run the socat command:

    socat tcp-listen:<x>,fork tcp:localhost:<y>

    Where:

    <x> is the port number on the target machine that UFT One tries to access

    <y> is the CEF remote debugging port exposed for debugging on the target machine

  3. Disable or change the firewall to allow the relevant port.

UFT One is now able to work with remote applications through the port you defined for <x>.

For more details, see: http://stackoverflow.com/questions/6827310/chrome-remote-debugging-doesnt-work-with-ip

Back to top

PhantomJS

Run tests on the PhantomJS toolkit without any changes in your existing test.

To do this, perform the following steps:

  1. Add the phantomjs.exe file to the <UFT One installation folder>\bin\PhantomJS directory.

    This file is accessible as part of your PhantomJS download. For details, see http://phantomjs.org

  2. In the Record and Run Settings, select PhantomJS as your browser.

  3. UFT One uses a newer WebDriver version, which does not support PhantomJS. To downgrade your WebDriver to support Phantom JS, do the following:

    Replace the WebDriver.dll and WebDriverHost.exe files in the <UFT One installation folder>\bin folder with the ones in <UFT One installation folder>\bin\WebDriver\3.0.1.0.

When you run your test, UFT One will launch the installed version of PhantomJS and run the test on the toolkit.

Note: Recording is not supported for PhantomJS.

Back to top

See also: