Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

protractor-parallel-instances

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protractor-parallel-instances - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

2

package.json
{
"name": "protractor-parallel-instances",
"version": "1.0.15",
"version": "1.0.16",
"description": "Helps in creating dynamic instances based on the conf file passed",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -93,1 +93,45 @@ ## protractor-parallel-instances

[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
### • Problem statement:
Protractor uses a static configuration file for creating driver sessions
In some cases, we need to use other browsers(same/different) in parallel with native browser/appium sessions opened by protractor.
One such case being, when we use protractor with Appium and if we need to provide support for test-cases which
interacts with Appium and desktop browser simultaneously, then we have a problem
### • Solution:
There is a npm package created to handle such situtations which lets you dynamically create multiple browser sessions without
affecting existing driver sessions based on the configuration file provided.
https://www.npmjs.com/package/protractor-parallel-instances - Navigate to the
package to get installation instructions.
### • Usage instructions:
How to create a new browser session:
Import protractor conf file and pass the imported 'config' object to createNewBrowser method of ParallelInstanceHelper class
const newBrowser = await ParallelInstanceHelper.createNewBrowser(config);
There are two ways to work with newly created browser:
1. Finding elements using local browser reference:
newBrowser.element(By.css('selector')).click();
newBrowser.element(By.css('selector')).sendKeys('Test');
2. Overriding global objects with newly created 'newBrowser' object
This approach can also be implemeneted in two ways:
a. Calling 'await ParallelInstanceHelper.switchToNewBrowser();' to switch to new browser and calling 'await ParallelInstanceHelper.switchToDefaultBrowser();' to switch to default browser:
This will override the global object- 'browser' content with newly created 'newBrowser'. In case of any error in your script, as globals have been overriden by 'switchToNewBrowser' method, all the tests will run against newly created browser.
b. Overriding global only for specific code block by calling 'await ParallelInstanceHelper.executeInNewBrowser';
await ParallelInstanceHelper.executeInNewBrowser(browser, newBrowser, async () => {
await browser.get('https://google.com');
await browser.element(By.css('selector')).click();
await browser.element(By.css('selector')).sendKeys('Test');
});
This block using try-finally block, so even in case of any error during execution; Global object will be again set to default browser
### • Things to be taken care:
New instances created by calling 'createNewBrowser' method are not handled by protractor runner, so closing of these browsers needs to be done explicitly
Calling 'await ParallelInstanceHelper.closeBrowser();' will close the first locally created browser.
Note: closeBrowser also accepts index of browsers for closing them.
0 being the index of native browser and 1 to n being indexes of locally created browsers

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc