How can I create a selenium web driver test on Ubuntu 20.04?

Currently, I am working on setting up a test using selenium-webdriver in my project running on Ubuntu 20.04

I successfully installed it using yarn add selenium-webdriver. However, I am facing an issue with safaridriver which seems to be missing.

Whenever I execute the command npx mocha test/**/*.spec.cjs, I encounter the following error message:

The version of safari cannot be detected. Trying with latest driver version

Error: Unable to obtain browser driver. For more information on how to install drivers see https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/. Error: Error executing command for /home/new/projects/projectName/node_modules/selenium-webdriver/bin/linux/selenium-manager with --browser,safari,--output,json: safaridriver not available for download

const { By, Builder, Browser } = require('selenium-webdriver');
const { suite } = require('selenium-webdriver/testing');
const assert = require("assert");



suite(function (env) {
  describe('First script', function () {
    let driver;

    before(async function () {
      driver = await new Builder().forBrowser('chrome').build();
    });

    after(async () => await driver.quit());

    it('First Selenium script', async function () {
      await driver.get('https://www.selenium.dev/selenium/web/web-form.html');

      let title = await driver.getTitle();
      assert.strictEqual("Web form", title);

      await driver.manage().setTimeouts({ implicit: 500 });

      let textBox = await driver.findElement(By.name('my-text'));
      let submitButton = await driver.findElement(By.css('button'));

      await textBox.sendKeys('Selenium');
      await submitButton.click();

      let message = await driver.findElement(By.id('message'));
      let value = await message.getText();
      assert.strictEqual("Received!", value);
    });
  });
}, { browsers: [Browser.CHROME, Browser.FIREFOX] });

Any suggestions on how to resolve this safaridriver issue?

Thank you

Answer №1

  1. It raises a red flag for me if Safari is mentioned in a conversation about Ubuntu, as it is a MacOS browser. I would investigate why Safari is being brought up.
  2. Simply running `yarn install` may not be sufficient; you may need to install native packages like `apt install chromium-driver`. In some cases, manual installation of the driver (`chromedriver_linux64.zip`) might be necessary depending on your setup. Once all dependencies are in place, hopefully the system will stop looking for Safari.
  3. Getting Selenium up and running can be tricky, as matching the versions of Chrome and the Chrome driver is crucial. There are also various driver parameters that require careful consideration - diving into these details would be too lengthy at this point.

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

Interacting Shadows with BufferGeometry in react-three-fiber

I've been working on my custom bufferGeometry in react-three-fiber, but I can't seem to get any shadows to show up. All the vertices, normals, and UVs are set correctly in my bufferGeometry, and I even tried adding indices to faces, but that just ...

Improving Zen Coding to integrate with JavaScript files on Sublime Text2

Sublime Text2 is hands down my go-to editor, except for one minor hiccup - the Zen Coding plugin only works with CSS and HTML files. There are plenty of times where I'd love to use Zen Coding with JavaScript or other file types, like incorporating HTM ...

Seamlessly adaptive HTML5 video playback

Has anyone figured out how to make an HTML5 video in an absolutely positioned <video> element resize to fit the window width and height without ever getting cropped? Many solutions I've come across rely on using the <iframe> tag, which is ...

Error encountered: AngularJS routes causing 500 internal server error

I am struggling with organizing my directory structure. Here is how it currently looks - -project -public -app -app.js ( angular app module ) -server -server.js ( node root js file ) -includes -layout.jade - ...

Having difficulty including a class in the Node.js index file

My configuration class is located at: ProjectDir/classes/config.js 'use strict'; class config{ getMongo(){ var MongoClient = require('mongodb').MongoClient; MongoClient.connect('mongodb://127.0.0.1:27017/nodedb ...

Swapping between running programs with JavaScript

Challenge: I am exploring the possibility of establishing a communication loop between a server-side program and client-side JavaScript. The idea is that all outputs from the program should be transmitted to JavaScript for user display, while all user inp ...

What is the best way to clear and fill a div without causing it to resize?

I am faced with a challenge involving four thumbnail divs labeled .jobs within a #job-wrap container. When a .job is clicked, I want the #job-wrap to fade out, clear its contents, load information from the selected .job, and then fade back in. However, whe ...

Can you explain the mechanics behind the animation of the upvote button on steemit.com?

Behold the upvote button of steemit.com: <span class="Icon chevron-up-circle" style="display: inline-block; width: 1.12rem; height: 1.12rem;"> <svg enable-background="new 0 0 33 33" version="1.1" viewBox="0 0 33 33" xml:space="preserve" xmlns=" ...

How can I ensure that the scrollbar stays at the bottom using CSS at all times?

I have a container with a scrollbar containing various contents, functioning as a widget. Upon initialization, I position the scrollbar at the bottom. My aim is to ensure that regardless of any changes in the parent element or its placement elsewhere, the ...

Instant Pay Now Option for Your WordPress Website with PayFast Integration

I have encountered an interesting challenge that I would like some guidance on. My goal is to integrate a PayFast "Pay Now" button into a Wordpress.com blog, specifically within a sidebar text widget. The tricky part is that I need the customer to input th ...

Encountering a ValueError when attempting to validate form fields with Django and JavaScript

I encountered an error while trying to validate a field using Javascript and Django. Error: ValueError at /insert/ invalid literal for int() with base 10: '' Request Method: POST Request URL: http://127.0.0.1:8000/insert/ Django Version: ...

Utilizing Proxy IP with Selenium Webdriver

While performing data scraping on a website using selenium webdriver, I encountered an issue where heavy traffic from my IP address caused me to lose access to the website (potentially due to my IP being blocked). Is there a way to configure a proxy IP so ...

Obtaining information to facilitate two-way data binding

How can I access data from a method defined within an onclick function? onclick: function(d, i) { $scope.country = d.name; console.log($scope.country); } I am trying to retrieve the name from the object and display it in an HTML <h1>Clicked: {{ ...

Is it possible to implement PortalVue in multiple Vue.js single file components?

While working on Vue.js (single file components), I have discovered three methods of passing data around: local state/props, store, and utilizing PortalVue. Through my experiments with PortalVue, I successfully implemented both portal and portal-target wit ...

Having trouble putting Protractor to "rest"

Having trouble getting Protractor to rest. I have the following line in my spec file: browser.driver.sleep(5000); I've experimented with different solutions, but none of them seem to be effective.. Your assistance is greatly appreciated. ...

Artwork - Circular design disappears without warning

While working on a clock project purely for enjoyment, I noticed that the minute arc disappears from the canvas as soon as a new minute begins. Any idea why this is happening? Check out the clock in action: https://jsfiddle.net/y0bson6f/ HTML <canvas ...

Send a quick message with temporary headers using Express Post

When creating a response for a post request in Express that returns a simple text, I encountered an issue. var express = require('express'); var app = express(); var bodyParser = require("body-parser"); var multer = require('multer') ...

Tips for converting an asynchronous process to operate as a synchronous process

Hey there! Checkout this piece of code I have function executeBat(){ var process = require('child_process').exec; process('C:\\Temp\\tasks\\acis\\runme.bat', function(error, stdout, std ...

Issue with parsing JSON data for heatmap in Mapbox

Here's the code I'm using: heat = L.heatLayer([], { maxZoom: 12 }).addTo(map); $.getJSON("js/example-single.geojson", function(data) { var geojsosn = L.geoJson(data, { onEachFeature: function (feature, layer) { console.log(f ...

Steps for creating a resizable and automatically hiding side menu

I am working on a side menu that can be resized, and I want it to collapse (set to zero width) when it is empty. I have considered implementing one of these features individually, but I'm not sure how to make both work together. Is there a way to ad ...