"Encountered an error message: Unable to retrieve property 'getCapabilities' due to a TypeError

Everything was going smoothly with my tests until I encountered an issue when the browser.getCapabilities(); method was called in the OnComplete function, resulting in an error.

    //The HTMLReport is triggered once all tests are completed
  onComplete: function () {
    var browserName, browserVersion;
    browser.getCapabilities();
    capsPromise.then(function (caps) {
      browserName = caps.get('browserName');
      browserVersion = caps.get('version');
      platform = caps.get('platform');
      var HTMLReport = require('protractor-html-reporter-2');
      testConfig = {
        reportTitle: 'Protractor Test Execution Report',
        outputPath: './reports',
        outputFilename: 'ProtractorTestReport',
        screenshotPath: '..//screenshots',
        testBrowser: browserName,
        browserVersion: browserVersion,
        modifiedSuiteName: false,
        screenshotsOnlyOnFailure: true,
        testPlatform: platform
      };
      new HTMLReport().from('xmlresults.xml', testConfig);
    });

Here is the error from the console:

E/launcher - Error: TypeError: Cannot read property 'getCapabilities' of undefined
    at onComplete (/Users/Testbook/Documents/protractorproj/conf/conf.js:63:13)
    at /usr/local/lib/node_modules/protractor/built/frameworks/jasmine.js:115:27
    at module.exports.jasmineDone (/usr/local/lib/node_modules/protractor/node_modules/jasmine/lib/reporters/completion_reporter.js:15:5)
    at dispatch (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4366:28)
    at ReportDispatcher.jasmineDone (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4337:11)
    at QueueRunner.onComplete (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:994:18)
    at Immediate._onImmediate (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4231:12)
    at processImmediate (internal/timers.js:461:21)

Answer №1

The code snippet at the beginning of my conf.js file turned out to be the issue. I have no idea how it ended up there as I did not include it myself.

const { browser } = require('protractor');

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

Can the keys of an object be retrieved in a specific order?

Is it possible to retrieve keys from a JSON object in the exact same order they were originally received? The use of Object.keys(company).length currently seems to be functioning, but I am seeking reassurance that this method will consistently deliver acc ...

Exploring the possibilities of implementing the .map() function on a JSONArray within a ReactJS project using ES

When I receive a JSONArray from the server, my goal is to use .map() on it in order to extract key-value pairs of each object within the array. However, when I try to implement this code, I encounter an error stating "files.map is not a function". Can some ...

How to troubleshoot Props not functioning in nextjs-typescript?

I'm having trouble with props in my project and I can't seem to figure it out! Here are the three files. I'm still learning typescript but everything seems fine in the code, yet it's not working! Here is index.tsx file: const Home: ...

Guide to incorporating a vanillaJS npm script into a Nuxt plugin

Struggling with saving images directly to AWS S3 using AWS S3. Attempted to add the AWS package as a plugin without success. In the nuxt.config.js file, I have: plugins: [ ... '~plugins/S3.js' ], In the plugins/s3.js file: import vue from ...

Implementing hover intent functionality in Angular 2+

Struggling to incorporate hover intent in Angular 2. Any advice or suggestions would be greatly appreciated. ...

Optimal method for parsing URLs using ES6

There have been many remarkable inquiries regarding this topic, such as: how to parse a url. However, as time has gone by, the answers I come across are outdated. I am looking for a more modern and flexible method to parse URLs, without relying on regular ...

What is the best approach for scaling @material-ui Skeleton in a grid row with variable heights?

I am working on creating a grid of Avatar images with a transition state where I want to show a skeleton representation of the image. To achieve this, I am using @material-ui/lab/Skeleton. The issue I'm facing is that since my images are set to autos ...

Custom HTML form created by Ryan Fait with additional unique elements

My current script for styling checkboxes and radiobuttons is working perfectly: The issue arises when I dynamically add checkboxes and radiobuttons to the page using jQuery. The new elements do not inherit the custom styling. Is there a workaround for th ...

Tips for centering the InputLabel in Material UI?

Upon loading the page, I am looking to have the InputLabel appear as shown in the second picture. However, I haven't been able to find any InputLabel props that achieve this. I attempted using the focused prop, but it didn't give me the desired o ...

Next JS throwing internal server error when authenticating with axios

I'm encountering a 500 internal server error when trying to authenticate with Next Auth. I followed the documentation from Next Auth for implementation. import NextAuth from "next-auth"; import CredentialsProvider from "next-auth/provi ...

What is causing my tooltips to flicker in Firefox but not in Chrome?

When I tried viewing the provided fiddle in Firefox (version 5.0.1 on a Mac), I noticed that when hovering over a day in the calendar and placing the mouse pointer inside the tooltip, the tooltip would flash on and off. Interestingly, this issue did not oc ...

Confirm before closing the window

How can I get this code to function properly and show a confirmation alert after the user clicks on a button? This is essentially an "exit website button". The confirmation pop-up will have: If "OK" is clicked > the current window will close; If ...

Having trouble getting my JS/CSS code to work for a single image music play/pause button. Any suggestions on how to fix it?

I'm currently working on a project and trying to incorporate a music button into the navigation bar. The goal is for the song to play when clicked, and then pause when clicked again. However, I've encountered some issues with getting it to functi ...

In JS/JSON, a new line of data is generated every hour

Recently, I have been experimenting with DiscordJS and exploring its logging functionality. I am aware that the method I am using is outdated and may not be the most secure for actively changing data, but I am intrigued. let count = JSON.parse(fs.readFile ...

using conditional statements in an app.get() method in express js

app.get('/api/notes/:id', (req, res, next) => { fs.readFile(dataPath, 'utf-8', (err, data) => { if (err) { throw err; } const wholeData = JSON.parse(data); const objects = wholeData.notes; const inputId ...

Top Reasons for Developing a Maven Project for Automation Testing

Having just started my journey in automation testing, I find myself struggling to grasp the rationale behind setting up a Maven project for developing automation test scripts with Selenium. Any advice or guidance would be greatly appreciated. ...

Is there a specific HTML tag available to instruct the browser to cache my HTML and/or CSS files for future use?

Up to this point, my research has indicated that enabling JavaScript and CSS browser caching typically requires server side settings such as .htaccess. Is there any HTML tag or configuration within the HTML page or JavaScript that can instruct the browse ...

Any recommendations for updating input in a directive without relying on $broadcast?

I am currently facing an issue with my contact list on controller A. Whenever I select a contact, the contact's information gets broadcasted to controller B and also to the datepicker directive in controller B. Although this method works, I am wonderi ...

Determine the position of the cursor in an editable span

Is there a way to add text at the cursor position in an editable span when a button is clicked? The span contains multiple lines of text and HTML tags. [Take a look at this example on JSFiddle](http://jsfiddle.net/8txz9sjs/) ...

Reduce the number of days from a specified ISO date

How can I calculate the number of days between today and a date that's stored in my MongoDB database in ISO format? Your help is greatly appreciated. let ISOdate = ISODate("2020-12-25T20:40:08.295Z") let difference = newDate() - ISOdate; i ...