protractor-parallel-instances
Advanced tools
Comparing version 1.0.15 to 1.0.16
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
137
1
32756
9
223