Grid Execution with Protractor
There are two main aspects of running Protractor tests in the grid. The first aspect is initiating a test session and the other is running test in parallel on multiple devices.
Initiating a Test Session
To initiate a test session and run a Protractor test on the grid, certain capabilities must be specified in the Desired Capabilities object. The capabilities are:
- Authentication with Protractor
- Cloud URL - the URL of the cloud.
In addition, the Protractor test desired capabilities may include the following capabilities:
-
testName - Specifies the test name. This name will appear in SeeTest Reporter and in the generated report
-
generateReport - By default every Protractor test generates a report and takes screenshots after each command. To disable reports (and screenshots) pass this capability with a false value
-
takeScreenshots - take a screenshot of reports and the device reflection in the Grid page
-
platformName - run the test on the specified platform (Mac, Windows, iOS, etc...)
-
browserName - run the test on the specified browser (default is chrome)
-
browserVersion - run the test on the specified browser version (check which version are supported in your lab)
-
newCommandTimeout - change the default timeout for each command in the test (default is 300 seconds)
-
newSessionWaitTimeout - change the default timeout for creating a new driver (default is 300 seconds)
If the Protractor test is configured to generate report, when the test is finished a detailed report will be created in SeeTest Reporter.
Below you can find an example written in Javascript specifying the capabilities above.
Protractor- Grid Execution
exports.config = {
capabilities: {
'generateReport':false,
'takeScreenshots':false,
'browserName': 'chrome',
'platformName': 'mac',
'browserVersion': '61',
'accessKey': '<accessKey>' // can be use instead of username,password and project.
//'username': '<cloudUsername>',
//'password': '<cloudPassword>',
//'projectName': '<cloudProject>' //only required if your user has several projects assigned to it. Otherwise, exclude this capability.
},
seleniumAddress: 'http://yourcloudaddress:port/wd/hub', //use https if the cloud doesn't use SSL
......
};
Parallel Execution
If you run a test using the capabilities as they appear above, it will run on one device only. However, if you run this test on multiple threads, every thread creates a different instance of the test class which in turn initiates another test request. Running tests in parallel requires that you understand the concept of multi-threaded execution (either by built-in specific language implementations or using unit testing frameworks). It also requires that your license includes the ability to run tests on multiple nodes.