The driver instance that has forked will never cease

Issues arise when attempting to run multiple browser windows in Protractor. The code snippet being tested is as follows: I create a new browser instance to perform certain tests. When input is entered into the original browser, it should not affect the newly created one. While everything seems to function properly, the additional browser instance never shuts down after testing and an error message appears in the output.

The test suite:

'use strict';

describe('testing', function () {
    it('should work', function () {
        browser.get('http://angularjs.org');
        var browser2 = browser.forkNewDriverInstance(true);
        element(by.name('as_q')).sendKeys('search');
        expect(browser2.element(by.name('as_q')).getText()).toBe('');
    });
});

Configuration settings:

exports.config = {
    framework: 'jasmine2',
    capabilities: {
        'browserName': 'chrome'
    },
    baseUrl: 'http://localhost:4000',
    specs: 'test.spec.js',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};

Output displayed while running Protractor in the terminal:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://<my-ip-adress>:54721/wd/hub
Started
.


1 spec, 0 failures
Finished in 8.755 seconds
Shutting down selenium standalone server.

/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145
      callback(new Error(message));
               ^
Error: ECONNREFUSED connect ECONNREFUSED
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145:16)
    at ClientRequest.emit (events.js:95:17)
    at Socket.socketErrorListener (http.js:1552:9)
    at Socket.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:442:13)
From: Task: WebDriver.quit()
    at [object Object].webdriver.WebDriver.schedule (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:360:15)
    at [object Object].webdriver.WebDriver.quit (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:443:21)
    at /usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:59:14
    at [object Object].promise.ControlFlow.runInFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
    at [object Object].promise.Callback_.goog.defineClass.notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
    at [object Object].promise.Promise.notify_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
    at Array.forEach (native)
    at Object.goog.array.forEach (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/array/array.js:203:43)
    at [object Object].promise.Promise.notifyAll_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16)
    at [object Object].goog.async.run.processWorkQueue [as _onTimeout] (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
[launcher] Process exited with error code 1

Using Protractor version 2.0.0.

Why does the forked driver instance not close automatically like the main browser does? Is manual closure required before terminating the Selenium server?

Answer №1

Remember to always manually close the second session in protractor, as only the main one will be automatically closed.

To do this, simply include:

browser2.quit();

Answer №2

The issue at hand is that you are attempting to quit the original driver instead of the forked one.

Instead of forking, have you considered using something like

browser = new Browser();

Hopefully with this change, your 'new' browser will successfully close.

Another possible solution would be to utilize the WebDriver's driver.switchTo().frame() method

You can make a selection using:

  1. A number (0 based index)
  2. A name or ID
  3. A previously found WebElement (perhaps the simplest option for you)

Once you have made the switch, you should be able to quit without any issues.

Answer №3

I encountered a similar issue while working on a side project. To solve it, I decided to fork Protractor and make a modification by commenting out a particular section of code that was causing the server to stop prematurely. Here is the snippet of code that I modified:

//self.server_.stop().then(function() {
       deferred.resolve();
//});

Although this solution may not be elegant, it served its purpose for my simple project. I apologize if my approach seems like a hack, but hopefully, it can offer some guidance to those more experienced with Protractor than myself.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The AJAX validation process fails to run prior to the execution of the login PHP script

My attempt to implement AJAX for form validation is not successful and I'm unsure why. Despite my efforts, the form still redirects to login_action.php instead of performing the AJAX validation as intended. I have designed a modal login form and wish ...

Customize your file input with Bootstrap 4 using bs-custom-file-input and create a Symfony 5 collection with dynamic upload fields

The issue of not having a label for the chosen filename in a bootstrap 4 upload field has been resolved using the plugin https://github.com/Johann-S/bs-custom-file-input You can utilize "bs-custom-file-input" to showcase the selected filename in the boots ...

Transform my Curl script into a NodeJS app

I'm trying to replicate the functionality of a curl command within my NodeJS application, but I am facing some difficulties. Any guidance on how to achieve this would be greatly appreciated. curl -H "Authorization: bearer $TOKEN" If I already hav ...

Dynamically Loading CSS files in a JQuery plugin using a Conditional Test

I'm trying to figure out the optimal way to dynamically load certain files based on specific conditions. Currently, I am loading three CSS files and two javascript files like this: <link href="core.min.css" rel="stylesheet" type="text/css"> & ...

Utilizing form data to upload images and send them back to the front end within a React js application

I am working on a project using NestJS and React JS to create an image uploader. In React, I have the following setup: const props = { onChange({ file, fileList }: any) { const fd = new FormData(); fd.append('img& ...

Downloading files automatically from a webpage

Seeking a way to automatically download a file from a website, as the current manual process is cumbersome. Each time involves logging in, navigating to the file, and clicking download. If anyone has advice on automating this task using tools like MS DOS ...

Ajax causing unreliable posts

I am facing an issue with sending and receiving data in my mobile application. I currently use the jquery $.post function, but it seems to be quite unreliable. Issue: Occasionally, about 1 out of 10 times, the POST request is sent successfully, but the ca ...

Highlight and trim lengthy text using React

Imagine I have a lengthy text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo con ...

Utilizing erb within a coffeescript file for modifying the background styling

Is there a way to change the background image of a div based on user selection from a dropdown menu? For instance, if the user picks "white" the background image becomes white, and for "red" it changes to red. I'm struggling with this in coffeescript ...

Guide to forming an array by extracting specific properties from a nested JSON array using javascript

Currently, I have this list: list = { id: 1, arr: [ {index : 1 , description: "lol" , author: "Arthur"}, {index : 2 , description: "sdadsa" , author: "Bob"}, {index : 3 , desc ...

Error message: org.apache.jorphan.util.JMeterException: Unable to execute bsh method: evalSourced script: inline evaluation of:

After upgrading from selenium-server-standalone-2.53.0 to selenium-server-standalone-3.1.0 in the %Jmeter%lib folder, I encountered the following error: Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced fil ...

What is the process for setting up a resthook trigger in Zapier?

I'm currently integrating Zapier into my Angular application, but I'm struggling with setting up a REST hook trigger in Zapier and using that URL within my app. I need to be able to call the REST hook URL every time a new customer is created and ...

What is the best way to style HTML content with MathJax following its retrieval with jQuery.load?

I recently encountered an issue while using jQuery.load to load a new page. The content on the original page is being treated strangely in some way. Specifically, I have code on the original page that formats LaTeX commands with MathJax: <script type=" ...

Implementing Angular2 with conditional loading

One of the requirements for my project is to redirect users to the login page before loading the Angular2 application, without actually loading it. The project is built using angular2-quicksart. After minifying the Angular2 js file: <script> va ...

Wookmark js isn't designed to generate columns from scratch

I am attempting to utilize the Wookmark jQuery plugin in order to create a layout similar to Pinterest. However, I am encountering an issue where Wookmark is not creating columns within the li elements, instead it is simply stacking images on top of each o ...

How can I implement a feature to automatically close a drawer in a React application using the Material UI

Currently, I am utilizing a React material design theme However, I am facing an issue where the drawer navigation button on mobile view does not close automatically upon clicking I need something like (onClick={handleClose}) to resolve this problem Does ...

Creating an alert pop-up that displays text based on the prompt input type: A step-by-step guide

I'm a new to Javascript and I'm trying out some basic scripts. My objective is to display a prompt message (1.) asking for a name, then show an alert (2.) based on the input from the prompt. If the input is a valid name (a string), then the alert ...

Retrieving an item using a known path even without the id information

I am currently developing a testing program that functions under limited information. In this specific scenario, my program lacks prior knowledge of the element IDs on the page as they are assigned dynamically by Javascript at runtime. The only constants ...

Disregard the sorting of rows in the MUI Datagrid

Any advice on excluding the "TOTAL" row from sorting in MUI library? onSortModelChange={(test, neww) => { neww.api.state.sorting.sortedRows = [14881337, 2, 3] neww.api.setState({...neww.api.state}) } } Review ...

I'm having trouble getting onClick to function properly in CodeIgniter

While attempting to utilize onClick in the PHP page as shown below: <a href="javascript:void(0);" onClick="deleteCourse('<?php echo $row->courseId;?>');" class="delete">Delete</a> And in the JavaScript page, the function is ...