Use Selenium Webdriver on Ubuntu with .NET Core 7

First update your system

apt update
apt upgrade

Next download google-chrome


Next install ‘google-chrome’

dpkg -i google-chrome-stable_current_amd64.deb

If you have a problem with your dependencies after the previous step, run the following command then try again the previous step.

sudo apt -f install

Verify your version of google-chrome

google-chrome --version
# Google Chrome 123.0.6312.86

Create a new console program

dotnet new console -n SeleniumExample
cd SeleniumExample

Install required packages

dotnet add package Selenium.WebDriver
dotnet add package Selenium.WebDriver.ChromeDriver

Edit your Program.cs file and replace its contents with the code below.

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
    static void Main(string[] args)
        // Set up the ChromeDriver
        var options = new ChromeOptions();

        using var driver = new ChromeDriver(options);

        // Navigate to a website

        // Wait for the results to load and display the title
        driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

        // Close the browser

Run the program, it should show the title of the webpage


Leave a Reply

Your email address will not be published. Required fields are marked *