Troubleshooting issues encountered while using mocha and selenium webdriver with npm

While trying to run Selenium webdriver with Node and Mocha on Ubuntu 18.04, I encountered the following errors:

  1) Google search automated testing
       find the input box and google search button:
     TimeoutError: Element not found
Wait timed out after 15002ms
      at /root/test/node_modules/selenium-webdriver/lib/webdriver.js:834:17
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

  2) Google search automated testing
       put keyword in search box and click search button:
     TimeoutError: Element not found
Wait timed out after 15005ms
      at /root/test/node_modules/selenium-webdriver/lib/webdriver.js:834:17
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)



[mochawesome] {
  "killed": false,
  "code": 3,
  "signal": null,
  "cmd": "xdg-open /root/test/mochawesome-report/mochawesome.html"
}

What additional details do you require? Is there a way to debug this issue?

I am currently using this repository as my base for experimentation. (https://github.com/bmshamsnahid/Automation-With-Selenium-And-Node.js)

Answer №1

Greetings! It appears that there may be an error with certificate validation. One workaround for this issue in Chrome is to disable it using the following option: --ignore-certificate-error

Answer №2

Removing the headless option results in:

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="25424a4a42494056404457464d65140b">[email protected]</a> test /root/test
> mocha test --reporter mochawesome --reporter-options autoOpen=true

Google search automated testing
  1) "before each" hook for "find the input box and google search button"
  2) "after each" hook for "find the input box and google search button"

  0 passing (456ms)
  2 failing

  1) Google search automated testing
       "before each" hook for "find the input box and google search button":
     WebDriverError: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:550:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:563:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:489:26)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

  2) Google search automated testing
       "after each" hook for "find the input box and google search button":
     WebDriverError: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:550:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:563:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:489:26)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

[mochawesome] {
  "killed": false,
  "code": 3,
  "signal": null,
  "cmd": "xdg-open /root/test/mochawesome-report/mochawesome.html"
}

npm ERR! Test failed. See above for more details.

It seems the solution to this error was indeed to run it headless.

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

What is the best way to add ajax data to a page without duplicating

When a user selects an option from the drop-down menu, I am attempting to add new data to my select tag. obj.prototype.getText=function(){ codes.... call ajax.... ajax.callback=function(data){ $('#option' ...

Forcing Package Updates in NPM without SemVer Restrictions

Is there a practical method to prompt an update for a node package? While it's beneficial that we are shielded from aggressive package updates, the process of upgrading even to a patch version seems cumbersome due to most versions being saved as exac ...

Tips for returning a false value when an element is not found on a page in Selenium WebDriver

Currently, I am delving into the world of automation and have encountered a common issue. Typically, I have set logic in my code that involves checking for the presence of an element, with the subsequent steps being dependent on the outcome of this check. ...

Different methods for concealing the display of CSS grid-area names

Currently, I am in the process of creating a user interface using CSS grid layout and HTML. The design involves numerous grid rows and columns. The structure of my CSS and HTML code is illustrated below: <!DOCTYPE html> <html> <head> ...

Using JavaScript to make an AJAX call to a different domain while bypassing the Content Security Policy restrictions

While parsing a web page, I need to initiate an AJAX call to my localhost depending on the content. The purpose is to exchange data using a PHP script on my localhost, possibly in JSON format (still under testing). This process is part of a plugin that I ...

When attempting to call a function after an unsuccessful AJAX load, the Jquery

Our catalog results page includes an external JavaScript file that utilizes AJAX - I have a jQuery function designed to change the color of a span when it detects specific text. You can view the code below: function ReInitStockColor(){ $(function() { ...

Leveraging mongoose populate in a Node.js environment with TypeScript

I am struggling to solve this issue. I am currently working on a node express mongoose server with code written in TypeScript and encountering the following error: Property 'populate' does not exist on type 'Document | Aggregate | Model | ...

The ng-submit() directive in Angular does not trigger submission when the "Enter" key is pressed in a text field

I have created a basic form using Angular where I want the ng-click function (updateMsg({name: name,room: room})) to be triggered when the user enters a value and then presses enter key. Unfortunately, the current code does not work as expected. The funct ...

Explore the fetch JSON API for efficient searching

After successfully fetching data from my API using React and obtaining JSON in my console, I am now faced with a new challenge. I have a search component that I want to use to search within the JSON data I retrieved and display the results on the screen. ...

What is the best way to integrate various JQuery and DataTables functionalities and organize them in a specific order

I managed to implement some features into jQuery datatables by following tutorials. However, I am struggling to combine these features and make them work together seamlessly. If you search for these features online, you will likely find where they originat ...

Enhance Your Highcharts Funnel Presentation with Customized Labels

I am working on creating a guest return funnel that will display the number of guests and the percentage of prior visits for three categories of consumers: 1 Visit, 2 Visits, and 3+ Visits. $(function () { var dataEx = [ ['1 Vis ...

Error message in Chrome extension: Unable to execute the 'appendChild' method on a null object while attempting to create an overlay div

I attempted to create a simple overlay div using a Chrome extension, and it usually works fine. However, I encountered an error on a few specific sites such as: http://en.wikipedia.org/wiki/Main_Page when trying to add the div. Below is the code I used: ...

Running into a problem with NPM installation that's causing it to stall and throw an error message (specifically: connect ENET

Has anyone else encountered an issue where running NPM install gets stuck on idealTree buildDeps and displays the following error? npm ERR! code ENETUNREACH npm ERR! syscall connect npm ERR! errno ENETUNREACH npm ERR! request to https ...

Utilizing switch_to() Method in Python to Handle Security Alert Dialog Boxes

Encountering a 'security warning' popup box issue while using Firefox. Currently working with Python and Selenium driver.switch_to().alert().accept() TypeError: 'SwitchTo' object is not callable Seeking recommendations to resolve th ...

Exploring routes using Google Maps JavaScript API v3

I've been facing challenges with the Google Maps JavaScript API as I attempt to manually parse the DirectionsResult data for display and later storage in a database. However, when iterating through the loop: for (i = 0; i < response.routes.length ...

Styling Images with Gradient using CSS

Looking to create a unique effect on an image by adding a radial gradient that seamlessly fades into the background color. Despite my efforts, I haven't been able to achieve this using filters and my current code is a bit messy. Here's what I ha ...

JavaScript unexpectedly populating array with unnecessary empty objects

During my attempt to create a calculator, I encountered an error while testing. After entering a number and selecting one of the operation buttons, I ran a console.log test and discovered 3 extra arrays lingering without purpose. You can find the JSFiddle ...

Require the ability to utilize two different versions of Java on a single computer

My project requires the use of Java 1.6, but I also need to run test cases using Java 1.7 compiled files. How can I achieve this? Can both Java 1.6 and Java 1.7 versions be installed on the same machine? If so, how can I set the Java 1.6 path for my appl ...

Tips for updating the contents of a div dynamically in JavaScript/jQuery without the need for clicking a button or a link

Is there a way to automatically reload or refresh the content of a specific div element without refreshing the entire page, and without any user interaction such as clicking a button or link? I am looking to update the div with the id 'div_graph' ...

Why is the $match function in Mongoose not functioning properly with an array of ObjectIds in Node.js

Greetings! I've been trying to match an array of objectIds in Mongoose using Node.js, and although I achieved the desired result in the Mongo shell, I'm facing difficulties when implementing the same in my code. Here's a snippet from my col ...