![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
protractor-parallel-instances
Advanced tools
Readme
A simple tool that allows you to create protractor browser instances based on the configuration file passed to createNewBrowser(*) method. You need to explicitly handle closing of browser as protractor does not handle it
Helps in creating new ProtractorBrowser instance based on the conf file passed into the arguments You need to close these browsers explicitly by calling closeBrowser() as protractor does not manage it Returns an instance of ProtractorBrowser
configurationFile
anywaitForAngularEnabled
booleanReturns Promise<ProtractorBrowser>
Switches the driver context to the global/default browser
Switches the driver content to local browsers index is an optional parameter, if there is only one local instance available then calling this method will switch the driver context to the local browser Otherwise an Exception is thrown to specify the browser index explicitly
index
Executes a piece of code in newly created driver and sets global values to default once function definition is executed
oldBrowser
native browsernewBrowser
browser created by calling createNewBrowser methoddefinition
verb - operations you want to performCloses locally create driver instances
index
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
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.
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
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
FAQs
Node package to create protractor browser objects on the fly
The npm package protractor-parallel-instances receives a total of 32 weekly downloads. As such, protractor-parallel-instances popularity was classified as not popular.
We found that protractor-parallel-instances demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.