This topic lists browsers supported by TestCafe and describes how to use various browser features.
- Browser Support
- Test in Headless Mode
- Use Chromium Device Emulation
Install Safari On Windows
Browser Support #
Officially Supported Browsers #
While TestCafe is designed to support most modern browsers, there are a limited numberof officially supported browsers. TestCafe is actively tested with these browsers.
- Google Chrome: Stable, Beta, Dev and Canary
- Internet Explorer (11+)
- Microsoft Edge (legacy and Chromium-based)
- Mozilla Firefox
- Safari
- Google Chrome mobile
- Safari mobile
TestCafe supports the latest version of each browser (unless specified explicitly).
The process of switching to new window/tabs involves looping through the list of windows or tabs that the Selenium WebDriver can see, post which you switch to the required window/tab. The tedious process of switching to new windows or tabs in Selenium Python is all set to change with Selenium 4. The newwindow API in Selenium 4 Python aids in. How to turn on and use the mobile browser emulator in Opera. In Opera, visit the web page that you want to view as if you were using a mobile device. Then click the Opera icon on the top-left ( 'Customize and control Opera' ). In the menu that opens, choose Developer followed by Developer tools. A quick look at how to enable Chrome's useful new Emulation Mode to emulate dozens of mobile devices. Ctrl+Shift+I on Windows. To simulate the standards support or quirks of Safari.
Locally Installed Browsers #
TestCafe automatically detects popular browsers installed on a local computer.You can use a short name - the browser alias - to identify browsers when you launch a test.
The following table lists browsers that can be detected automatically.
Browser | Browser Alias |
---|---|
Chromium | chromium |
Google Chrome | chrome |
Google Chrome Canary | chrome-canary |
Internet Explorer | ie |
Microsoft Edge (legacy and Chromium-based) | edge |
Mozilla Firefox | firefox |
Opera | opera |
Safari | safari |
Call the testcafe
command with the --list-browsers flag to view a list of all available browsers.
To run tests in a different local browser, specify the path to the browser's executable file.
To test in Microsoft Edge Chromium and Legacy on the same machine, install them side-by-side. Once installed, see the Microsoft Edge Legacy Support section below for information on how to enable testing in older versions.
For more information and examples, see the following:
- Command line: Local Browsers
- API: runner.browsers
- Configuration file: browsers
Portable Browsers #
To use a portable browser, specify the path to the browser's executable file. For more information and examples, see the following:
- Command line: Portable Browsers
- API: runner.browsers
- Configuration file: browsers
Browsers on Remote Devices #
To run tests on a remote mobile and desktop device, the device must have network access to the TestCafe server.
First, you will need to create a remote browser connection.
- Command line: specify the
remote
alias (see Remote Browsers) - API: use the createBrowserConnection method
- Configuration file: browsers
After that, TestCafe generates a URL to open in the browser that you need to test (on a remote device). This URL is then exposed through the API or displayed in the console. Access this URL from the desired browser. It then connects to the TestCafe server and starts the test.
Note that when you run tests in a remote browser, you cannot take screenshots or resize the browser window.
Browsers in Cloud Testing Services #
TestCafe allows you to use browsers from cloud testing services. You can access them through browser provider plugins.
The following plugins for cloud services are currently provided by the TestCafe team.
Service | Plugin |
---|---|
Sauce Labs | testcafe-browser-provider-saucelabs |
BrowserStack | testcafe-browser-provider-browserstack |
You can search npm for community-developed plugins. Their names begin with the testcafe-browser-provider-
prefix: https://www.npmjs.com/search?q=testcafe-browser-provider.
You can also create your own plugin. See Browser Provider Plugin for instructions.
Microsoft Edge Legacy Support #
Tests are run in Microsoft Edge Legacy if it is the only version of Edge installed on the machine.
If both Chromium-based and Legacy versions are available, you can change the default Edge application in System Settings to test with the Legacy version.
To test with the Legacy version of Edge, open Default apps in Windows Settings and scroll down to select Default Apps by Protocol. Set the MICROSOFT-EDGE:
protocol to Legacy Edge.
Nonconventional Browsers #
To run tests in a different type of browser, use a browser provider plugin.
You can search npm for community-developed plugins. Their names begin with the testcafe-browser-provider-
prefix: https://www.npmjs.com/search?q=testcafe-browser-provider.
You can also create your own plugin. See Browser Provider Plugin for instructions.
Test in Headless Mode #
How To Emulate Safari On Windows 10
TestCafe allows you to run tests in Google Chrome and Mozilla Firefox without a visible UI shell - in headless mode (Chrome Headless, Firefox Headless). Use the :headless
parameter to launch a browser in headless mode.
Specify a path to the browser executable if you use a portable version of the browser. Use the browser alias instead of the path:
prefix.
Note that Take screenshot and Resize window are fully supported in headless mode.
Automation Port #
Chrome and Firefox require a remote control port for TestCafe to attach to a browser instance. TestCafe automatically assigns a free port, but you can specify a custom port via the cdpPort
argument (for Chrome) or the marionettePort
argument (for Firefox).
Use Chromium Device Emulation #
You can run tests with Chromium's built-in device emulator in Google Chrome, Chromium and Chromium-based Microsoft Edge. Use the emulation
browser parameter.
Emulate a Device #
Specify the target device with the device
parameter.
Emulate Screen Size #
You can specify parameters like width
, height
, or orientation
to configure the device emulator.
Use Emulation in Headless Mode #
You can combine device emulation and headless mode.
Use Emulation in Chrome Portable #
To enable device emulation in Google Chrome Portable, use the browser alias. The path:
prefix does not work in this case.
Substitute a User Agent #
Use the userAgent
parameter to substitute a user agent string.
TestCafe relies on a user agent string to emulate browser behavior. Tests are not guaranteed to run correctly if you specify a user agent that is invalid or not supported by TestCafe.
JavaScript API #
When you launch TestCafe with JavaScript API, provide the user agent string in the runner.browsers method parameter. Escape semicolons from the TestCafe argument parser with a double backslash - as shown below:
Command Line Interface #
You need to escape special characters in the user agent string when you specify it in the command line. These characters include the following:
(backslash)
'
(single quote)'
(double quote),
(comma);
(semicolon):
(colon)
The way to escape special characters depends on the shell you use. You also need to escape semicolons from the TestCafe argument parser with an additional backslash.
The following examples show how to escape user agent screens in bash
and PowerShell
.
bash
In bash
, enter a dollar sign before the argument to allow single quotes. Escape special characters with a backslash and use a double backslash for semicolons - to escape them from the TestCafe argument parser:
PowerShell
In PowerShell
, escape special characters with a single quote and use a backslash for semicolons - to escape them from the TestCafe argument parser:
Emulator Parameters #
Use the following parameters to configure the Chrome device emulator. Specify them after the emulation
parameter as in the examples above.
After that, TestCafe generates a URL to open in the browser that you need to test (on a remote device). This URL is then exposed through the API or displayed in the console. Access this URL from the desired browser. It then connects to the TestCafe server and starts the test.
Note that when you run tests in a remote browser, you cannot take screenshots or resize the browser window.
Browsers in Cloud Testing Services #
TestCafe allows you to use browsers from cloud testing services. You can access them through browser provider plugins.
The following plugins for cloud services are currently provided by the TestCafe team.
Service | Plugin |
---|---|
Sauce Labs | testcafe-browser-provider-saucelabs |
BrowserStack | testcafe-browser-provider-browserstack |
You can search npm for community-developed plugins. Their names begin with the testcafe-browser-provider-
prefix: https://www.npmjs.com/search?q=testcafe-browser-provider.
You can also create your own plugin. See Browser Provider Plugin for instructions.
Microsoft Edge Legacy Support #
Tests are run in Microsoft Edge Legacy if it is the only version of Edge installed on the machine.
If both Chromium-based and Legacy versions are available, you can change the default Edge application in System Settings to test with the Legacy version.
To test with the Legacy version of Edge, open Default apps in Windows Settings and scroll down to select Default Apps by Protocol. Set the MICROSOFT-EDGE:
protocol to Legacy Edge.
Nonconventional Browsers #
To run tests in a different type of browser, use a browser provider plugin.
You can search npm for community-developed plugins. Their names begin with the testcafe-browser-provider-
prefix: https://www.npmjs.com/search?q=testcafe-browser-provider.
You can also create your own plugin. See Browser Provider Plugin for instructions.
Test in Headless Mode #
How To Emulate Safari On Windows 10
TestCafe allows you to run tests in Google Chrome and Mozilla Firefox without a visible UI shell - in headless mode (Chrome Headless, Firefox Headless). Use the :headless
parameter to launch a browser in headless mode.
Specify a path to the browser executable if you use a portable version of the browser. Use the browser alias instead of the path:
prefix.
Note that Take screenshot and Resize window are fully supported in headless mode.
Automation Port #
Chrome and Firefox require a remote control port for TestCafe to attach to a browser instance. TestCafe automatically assigns a free port, but you can specify a custom port via the cdpPort
argument (for Chrome) or the marionettePort
argument (for Firefox).
Use Chromium Device Emulation #
You can run tests with Chromium's built-in device emulator in Google Chrome, Chromium and Chromium-based Microsoft Edge. Use the emulation
browser parameter.
Emulate a Device #
Specify the target device with the device
parameter.
Emulate Screen Size #
You can specify parameters like width
, height
, or orientation
to configure the device emulator.
Use Emulation in Headless Mode #
You can combine device emulation and headless mode.
Use Emulation in Chrome Portable #
To enable device emulation in Google Chrome Portable, use the browser alias. The path:
prefix does not work in this case.
Substitute a User Agent #
Use the userAgent
parameter to substitute a user agent string.
TestCafe relies on a user agent string to emulate browser behavior. Tests are not guaranteed to run correctly if you specify a user agent that is invalid or not supported by TestCafe.
JavaScript API #
When you launch TestCafe with JavaScript API, provide the user agent string in the runner.browsers method parameter. Escape semicolons from the TestCafe argument parser with a double backslash - as shown below:
Command Line Interface #
You need to escape special characters in the user agent string when you specify it in the command line. These characters include the following:
(backslash)
'
(single quote)'
(double quote),
(comma);
(semicolon):
(colon)
The way to escape special characters depends on the shell you use. You also need to escape semicolons from the TestCafe argument parser with an additional backslash.
The following examples show how to escape user agent screens in bash
and PowerShell
.
bash
In bash
, enter a dollar sign before the argument to allow single quotes. Escape special characters with a backslash and use a double backslash for semicolons - to escape them from the TestCafe argument parser:
PowerShell
In PowerShell
, escape special characters with a single quote and use a backslash for semicolons - to escape them from the TestCafe argument parser:
Emulator Parameters #
Use the following parameters to configure the Chrome device emulator. Specify them after the emulation
parameter as in the examples above.
Parameter | Type | Description | Default |
---|---|---|---|
device (optional) | String | The emulated device name (see the full list of supported devices in DevTools -> ⠇-> Settings -> Devices). | No default value. |
width (optional) | Number | The device screen width in pixels. | The width of the selected device. If the device parameter is not set, the default browser width is used. |
height (optional) | Number | The device's screen height in pixels. | The height of the selected device. If the device parameter is not set, the default browser height is used. |
scaleFactor (optional) | Number | Device scale factor value. | Depends on the selected device or your system parameters. |
mobile (optional) | Boolean | Defines whether to emulate a mobile device. This includes the viewport meta tag, overlay scrollbars, text autosizing, etc. | true if a mobile device is set via the device property. Otherwise, false . |
orientation (optional) | vertical | horizontal | The device orientation | vertical |
userAgent (optional) | String | The user agent string | The user agent string of the selected device or the browser. |
touch (optional) | Boolean | Enables or disables touch event emulation. | true if a touch-supported device is set via the device property or your system supports touch events. Otherwise, false . |
cdpPort (optional) | Number | A port (0-65535) used for Chrome Debugging Protocol. Specify port 9222 if you use the :userProfile or --user-data-dir flag to load a user profile. | TestCafe automatically assigns a free port. |
User Profiles #
By default, TestCafe launches Chromium, Google Chrome, Microsoft Edge (Chromium-based, version 79 and above) and Mozilla Firefox with a clean profile (i.e. without extensions, bookmarks and other profile settings) - to minimize profile parameter influence on test runs.
However, if you need to start a browser with the current user profile, you can specify the :userProfile
flag after the browser alias.
When you pass the :userProfile
flag to a portable browser, also use the browser alias. The path:
prefix does not work in this case.
If you use the :userProfile
flag, set the cdpPort property to 9222
to record videos in Chrome and Chromium-based browsers.
It is not recommended that you combine the :userProfile
flag with either headless or emulation mode, because this can lead to unstable behavior.
Edit this Doc The Windows Driver
Appium has the ability to automate Windows PC Desktop apps. This driver relieson a project from Microsoft calledWinAppDriver, which is anAppium-compatible WebDriver server for Windows Desktop apps (and more in thefuture). WinAppDriver is often abbreviated 'WAD'. WAD is bundled with Appiumand does not need to be installed separately.
The Windows Driver supports testing of Universal Windows Platform (UWP) andClassic Windows (Win32) applications.
In addition to the WAD repo, development of the Appium driver takes place atthe appium-windows-driverrepo.
Requirements and Support
In addition to Appium's general requirements:
- Windows PC with Windows 10 or up
- Ability to enter Administrator mode
Usage
The way to start a session using the Windows driver is to include theplatformName
capability in your new session request, withthe value Windows
. Also, ensure that you set the deviceName
capability toWindowsPC
as well. Of course, you must also include an appropriate app
capability, at a minimum (see below).
Capabilities
How Do I Download Safari For Windows
The Windows driver supports a number of standard Appiumcapabilities. See below for how theseshould be used specifically with the Windows driver.
Setup
To test a Windows app, simply make sure you have turned developermodeon.
When running Appium (whether Appium Desktop or from the command line), ensurethat you have started the app / cmd prompt as an administrator.
Writing Tests for the Windows Driver
You could begin by taking a look at some existing samples:
Java Samples
1. Open the sample folder as an existing project in a Java IDE such as IntelliJ. For example: CalculatorTest2. In the Java IDE build and run the test
C# Samples
1. Pull and open CalculatorTest.sln
under CalculatorTest2. In Visual Studio 2015 with the test solution open build the test and select Test > Run > All Tests
Javascript/node Samples
Using selenium-webdriver
If you want to write tests from scratch, you can choose any programminglanguage or tools supported by Appium/Selenium to write your test scripts. Inthe example below, we will author the test script in C# using Microsoft VisualStudio 2015.
Create Test Project
- Open Microsoft Visual Studio 2015
- Create the test project and solution. I.e. select New Project > Templates > Visual C# > Test > Unit Test Project
- Once created, select Project > Manage NuGet Packages.. > Browse and search for Appium.WebDriver
- Install the Appium.WebDriver NuGet packages for the test project
- Start writing your test (see sample code under [samples])
Universal Windows Platform App Testing
To test a UWP app, you can use any Selenium supported language and simplyspecify the Application Id for the app under test in the appcapabilities entry. Below is an example of creating a test session for WindowsAlarms & Clock app written in C#: How to download fortnite on your phone.
When testing the application you authored yourself, you can find the Application Id in the generated AppXvs.appxrecipe
file under RegisteredUserNmodeAppID
node. E.g. c24c8163-548e-4b84-a466-530178fc0580_scyf5npe3hv32!App
Classic Windows App Testing
To test a classic Windows app, you can also use any Selenium supported languageand specify the full executable path for the app under test in the appcapabilities entry. Below is an example of creating a test session for WindowsNotepad app:
Starting a Session
As mentioned above, you should additionally use these capabilities to ensureyou are getting a Windows App automation session:
platformName
: Windows
deviceName
: WindowsPC
app
: the appID of the Windows app for testing, or the path to the .exe file How to ss on windows 10.
Inspecting UI Elements
Microsoft Visual Studio 2015 by default includes Windows SDK that providesgreat tool to inspect the application you are testing. This tool allows you tosee every UI element/node that you can query using Windows Application Driver.This inspect.exe tool can be found under the Windows SDK folder such asC:Program Files (x86)Windows Kits10binx86
. The tool will show variouselement attributes. The table below shows you which Appium locator strategy youshould use to find elements with the corresponding attributes.
Locator Strategy | Matched Attribute |
---|---|
accessibility id | AutomationId |
class name | ClassName |
name | Name |