Customize settings for Internet Explorer 11 with Javascript and Selenium

My current selenium javascript test setup includes the following chromedriver configuration:

const {Builder, By, Key, until} = require('..');    
const  webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('chrome').build();

I have followed the instructions to add IEDriverServer.exe to my PATH and verified the correct location and filename. Additionally, I have added the DWORD registry as per the tutorial. While all my configurations seem correct, I suspect I may be making incorrect assumptions about running tests with chrome versus internet explorer.

Here is what I am currently doing to run my IE Test:

const {Builder, By, Key, until} = require('..');
const  webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('internet explorer').build();
  1. Start Selenium Server by running java -jar selenium-server-standalone-3.9.0.jar in command prompt
  2. Double click on IEDriverServer.exe in another window to start it
  3. In a 3rd command prompt window, navigate to the folder where my tests and drivers are located and run the test using "node test2.js"

However, I encounter the following error message:

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:60381
    at ClientRequest.<anonymous> (<file path omitted>\index.js:244:15)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Any assistance on this matter would be greatly appreciated. Thank you!

Answer №1

Using various browsers such as firefox, chrome, and ie has worked well for me in the past. However, I have encountered issues with applying capabilities, which do not seem to function properly.

var webdriver = require("selenium-webdriver");

var DriverFactory = {
    create: function (browser) {
        if (browser == "ie" || browser == "internet explorer") {
            let capabilities = webdriver.Capabilities.ie();
            capabilities.set("ignoreProtectedModeSettings", true);
            capabilities.set("ignoreZoomSetting", true);
            return driver = new webdriver.Builder().withCapabilities(capabilities).build();
        } else {
            return driver = new webdriver
                .Builder().forBrowser(browser)
                .build();
        }
    }
}
module.exports = DriverFactory;

To use this module, simply import it into your code and make a call to it.

async function () {
    driver = await DriverFactory.create("firefox");
};

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

How can I select the nearest element in Vue.js when hovering with the mouse

This Element was created, a menu Band: <template> <div class="container-lg"> <nav> <ul class="nav justify-content-center"> <li class="nav-item" v-for="link in menuLinks" ...

Trouble with Basic JavaScript Comparison Function

I'm facing an issue with a JavaScript comparison that doesn't seem to be working. It's puzzling why it's skipping to line 12302 and setting showNoDataText = true. The logic dictates that it should be false since the array length of 285 ...

What is the advantage of using event.target over directly referencing the element in eventListeners?

Suppose there are several buttons in an HTML file and the following code is executed: const buttons = document.querySelectorAll('button'); buttons.forEach((btn) => { btn.addEventListener('click', (e) => { console.log(btn.te ...

Mapping JSON data with an elastic search cluster can be challenging, especially when dealing with a dynamic number of fields

I am currently developing an application where I need to map JSON data for storage in Elasticsearch. The challenge is that the number of fields in the JSON data is dynamic. How can I handle mapping in this scenario? Mapping Snippet var fs = uploadedFiles ...

What is the best way to measure the distance between two countries, between a country and a city, and between two cities?

What is the best method for determining the distance between two countries, between a country and a city, and between two cities? ...

Utilizing HTML5 Audio: Harness the Power of oncanplay and oncanplaythrough Events for Enhanced Audio Experience

There has been a suggestion to use both the oncanplay and oncanplaythrough events since the oncanplay event might not be consistent across all browsers: In my current implementation, I am only utilizing the oncanplay event. How can I modify my code to inc ...

Avoiding duplication of prints in EJS template files

In my EJS code, I have created a loop to fetch the total amount of items from the database. Here is my current code: <h2>Summary</h2> <% if(typeof items.cart!=="undefined"){ var amount = 0; %> <% i ...

Rails not recognizing Bower components

I have integrated angular and bootstrap into my Rails application using bower, but the JavaScript is not rendering properly. Both CSS and Java Script are not functioning Here is the code snippet: vendor\assets\javascript\application.js / ...

Adding participants using the Google Calendar API in JavaScript: A step-by-step guide

I am attempting to include attendees in a Google Calendar event using the API. The method I am currently using, similar to the update function, is not working as expected and is removing all previous attendees. Below is the code snippet: const attendees ...

Generate an array by collecting all the DIV elements, then proceed to compare for any

I need to create a form that checks if the user has entered a specific word in a textarea. These words are stored in arrays generated from divs. I am having trouble with the verification part, and I believe my arrays may not be created correctly. Take a l ...

What causes the failure of $event binding when using RowGroup tables with PrimeNG?

I have successfully implemented RowGroup to store 3 different tables, which is working great. However, I am facing an issue with the onRowSelect function not functioning properly. When I click on any row of the RowGroup tables, nothing happens. On another ...

Obtaining the top position with scrollpath.js

Is there a way to retrieve the top value from the following code snippet? <div class="sp-scroll-handle" style="top: 1.0416666666666665px; "> </div> I believe this value is generated by some JavaScript, possibly in the following function: fu ...

Set the radio button in Angular to be checked on the first option

I recently created a dynamic form with data from an API, including an ng-repeat to generate multiple radio buttons. Everything is working well, but I'm struggling to set the first radio button as checked by default. Any suggestions or solutions would ...

Selecting a date from a datepicker using Python's Selenium module

I am attempting to choose a date based on the numerical date. You can find the URL here: . Specifically, I am trying to select the starting month and date. wait.until(EC.element_to_be_clickable((By.XPATH, "//ul[@class='monthselect'][1]//li[t ...

What could be causing the unusual alignment of the 'pixels' on my resized HTML5 canvas?

Currently, I am in the process of creating a simple HTML5 canvas/JavaScript snake game inspired by the classic Nokia Snake. This is my first attempt at developing a game using HTML5 canvas and JavaScript, and I must admit, I am still a novice programmer! ...

Learn the steps for inserting or updating data in a local JSON file solely through JavaScript

Currently, I am in the process of reading a JSON file and removing an element once it finds an exact match. My goal is to then push the remaining data back into the JSON file after deletion. readJsonFile("./objects.json", function(jsonData){ let parsedD ...

Setting a custom expiration time for a custom token in Firebase authentication

Using the firebase custom auth, I have created a custom token. I am looking for a way to customize and update this token by shortening its expiry time based on when a session finishes. For example, if a session ends after 20 seconds or 5 minutes, I want to ...

Tips for retrieving text from within two identical child tags within a parent tag

Here is the HTML code snippet where I am attempting to extract the mobile number 7788996655 using XPath: <table class="table hover" id="resultTable"> <tbody> <tr class="odd"> <td class="left"> <img src=" ...

Steps for including a header and footer with page numbers in an HTML page without disrupting the rest of the content when printing

When I print a page with a table that spans multiple pages, I want to ensure that my header and footer are included on every page. The code I've tried so far has treated the entire content as one continuous page. How can I achieve this? ...

Is there a way to automatically collapse all the collapsible elements within the accordion when closing it?

I came across a similar topic on Stack Overflow about closing all children accordions when the parent accordion is closed, which seems to address my issue. Currently, I am using Bootstrap 4 and struggling to modify the code from the other topic to ensure ...