selenium icon indicating copy to clipboard operation
selenium copied to clipboard

selenium with edge and Internet Explorer 11 - Javascript client

Open MagicPoulp opened this issue 7 years ago • 0 comments

🐛 Bug Report

I create this issue so that people with difficulties can find it when searching.

I explain here how I made it to work to run tests for ie11 (internet explorer 11) and Microsoft Edge using latest versions on June 28 2019. I use the Javascript client selenium-webdriver.

webdriver starts the ie or edge driver on its own.

I assume you know how to set up a test suite. I only document here how to configure edge and ie.

To Reproduce

see below

Expected behavior

see below

Test script or set of commands reproducing this issue

see below

Environment

OS: Windows 10 pro for internet explorer you need IEDriverServer.exe on your path use an absolute path with $env:PATH += ';path_to_file' version 3.9 had a bug but 3.8 worked

for edge, you must install the driver version that suits you. for version 18 (edge html and edge chrome have 2 versions versions in one same browser) that I had, a powershell command is needed. Then the MicrosoftWebDriver.exe is reachable in a new powershell. Running the driver manually on the command line gave me which port I need for the config.

let driver;
switch (browserForWebdriver) {
  case 'internet explorer':
    // const capabilitiesIE = webdriver.Capabilities.ie();
    // the internet explorer driver does not allow the option below
    // for self-signed certificates
    // capabilitiesIE.set('acceptInsecureCerts', true);
    driver = (
      new webdriver.Builder()
      // .withCapabilities(capabilitiesIE) // set by default to ie with forBrowser()
        .forBrowser(browserForWebdriver)
        .build()
    );
    break;
  case 'MicrosoftEdge':
    {
      /*
        we need a custom solution for edge because the
        default session does not uses the right port
        the code below was taken from an example given in selenium-webdriver/lib/edge.js
      */
      // eslint-disable-next-line global-require
      const edge = require('selenium-webdriver/edge');

      const service = new edge.ServiceBuilder()
        .setPort(17556)
        .build();

      const options = new edge.Options();
      /*
        invalid certificate unsupported in the doc
        https://docs.microsoft.com/en-us/microsoft-edge/webdriver
        Accept Insecure TLS Certificates      "acceptInsecureCerts"   Not Supported   N/A
      */
      // options.set('acceptInsecureCerts', true);

      driver = edge.Driver.createSession(options, service);
    }
    break;
  default:
    driver = (
      new webdriver.Builder()
        .withCapabilities({ acceptInsecureCerts: true })
        .forBrowser(browserForWebdriver)
        .build()
    );
    break;
}

MagicPoulp avatar Jun 28 '19 15:06 MagicPoulp