Encountering an issue while attempting to execute a test on Google Chrome using Java and Selenium

Could anyone assist me? I am facing difficulties while running an automated test. The errors shown in the attached images are puzzling me and I am unable to come up with a solution. If anyone has experienced this issue before, please lend me your expertise.

Answer №1

  1. Begin by creating a new project and select the option to Use default JRE (1.8) https://i.sstatic.net/m0ED2.png

  2. Next, convert the project into a Maven project https://i.sstatic.net/LrL7J.png

  3. Then, add selenium dependency to the project

https://i.sstatic.net/yqTtp.png

  1. In the src folder, create a package named selenium https://i.sstatic.net/alYAY.png

  2. Create a source folder in the project, name it as resources https://i.sstatic.net/wMpCY.png

  3. Save chromedriver.exe in the resources folder and refresh the project

  4. In the src folder, create another package named tests with a class called Example1

  5. Download the required jars from this link: https://i.sstatic.net/SQIHb.png

  6. Now, enter the following code:

Create a selenium.ChromeDriverSetup class:

package selenium;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class ChromeDriverSetup {
    
    public static String chromedriverPath = System.getProperty("user.dir") + "\\resources\\chromedriver.exe";   

    public static WebDriver startChromeDriver() {
        System.setProperty("webdriver.chrome.driver", chromedriverPath);
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--ignore-certificate-errors");
        options.addArguments("--start-maximized");
        options.addArguments("--disable-notifications");
        WebDriver driver = new ChromeDriver(options);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        return driver;
    }
}

Write the tests in tests.Example1:

package tests;

import org.openqa.selenium.WebDriver;
import selenium.ChromeDriverSetup;
    
public class Example1 extends ChromeDriverSetup {

    public static void main(String[] args) {
        
        WebDriver driver = startChromeDriver();
        driver.get("https://www.stackoverflow.com");
        System.out.println(driver.getTitle());
        driver.quit();
        
    }
    
}
  1. Finally, run the test in Example1 class

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

JS issue: Having trouble accessing the array values despite the array being present

I am working on an ajax call where I save the success data in an array. However, when I try to access that data outside of the ajax function and use console to log my array, it appears as expected. Here is a glimpse at what I see on the screen: https://i ...

Determine the distance traveled by the mouse along a vector using Three.js

I am currently working on a project that involves determining the distance traveled by a mouse along a normal vector. The goal is to adjust a group of vertices within an object by moving them along the normal vector of an intersecting face. My current se ...

invoke the modal function from a separate React file

I am currently studying react and nextjs. I am experimenting with calling a modal from another file but unfortunately it's not functioning as expected. Here is the code I used: Signin.js import { Modal } from "react-bootstrap"; import { u ...

Having trouble creating a table using a JSON object in AngularJS

Click here to view the converted JSON object Please pay close attention to my question Hello, in the code below I am attempting to convert XML data into a JSON object. With this converted JSON object, I am aiming to create a table using AngularJS. The is ...

Can someone help me locate the file using the inspect element feature?

Today, I encountered a small issue on my website that I wanted to fix. Although I was able to make the necessary changes using Inspect Element, I couldn't locate the file where it needed to be changed. The website in question is gesher-jds.org/giving. ...

What is the best way to display the JSON array received from Postman on my HTML page using jQuery's Ajax success function?

I need help in iterating through the JSON array that is fetched from my API [{"a":1},{"b":2},{"c":3},{"d":4}]. How can I extract and display only the key-value pairs on my HTML output div? <body> <div id = "result" style = "color:green" > ...

Utilizing the split function within an ngIf statement in Angular

<div *ngIf="store[obj?.FundCode + obj?.PayWith].status == 'fail'">test</div> The method above is being utilized to combine two strings in order to map an array. It functions correctly, however, when attempting to incorporate the spli ...

How to Deactivate the Default Selection in React-Select

Having trouble with the focus in a React Select dropdown. The first item always gets focused when opening the dropdown, despite passing various props without success. I checked their GitHub for related issues around autofocus but couldn't find a solut ...

Tips for securely closing express servers to ensure that ports are properly released

One problem I have noticed, particularly on Mac computers, is that when I shut down a Node server using "CTRL + Z," the server stops running but the ports remain occupied. What is the correct method to close a server in order to release the ports and be a ...

Fix a carousel layout problem

I've made changes to an HTML-PHP module to display portfolio images as a carousel, and I'm using the same module on this website too. However, I've encountered an issue with duplicate content and the previous-next navigation buttons. Can so ...

angularjs currency conversion tool

Is it possible to choose only 3-4 currency values from a drop-down list, where the selected value will determine the base URL for fetching JSON data? For instance, if I select USD as the first value, the JSON data should be retrieved from . ...

Encountering issues while trying to establish a connection to MongoDB through JavaScript

I have developed a code for seamlessly integrating various social networking logins with nodejs. Below is my server.js file: // include the necessary tools var express = require('express'); var app = express(); var port = process.env ...

Enhancing material appearance by incorporating color gradient through the extension of three.js Material class using the onBeforeCompile method

In my three.js scene, I have successfully loaded an .obj file using THREE.OBJLoader. Now, I am looking to add a linear color gradient along the z-axis to this object while keeping the MeshStandardMaterial shaders intact. Below is an example of a 2-color l ...

What is the best way to manage and add dates in my database using Node.JS and MongoDB?

I am currently developing a Calendar application using Node.JS and MongoDB. However, I am encountering difficulties when trying to integrate data from the database into the existing calendar system. Whenever I attempt to load LocalHost:3000/init, I am pre ...

Is it possible to change the src attribute after the page has loaded and execute it

A. I'm trying to figure out how to dynamically change the src attribute of an image using JavaScript after the page has loaded. <img src="http://example.com/image.png" /> to <img src="http://domain.com/different.jpg" /> B. Another questi ...

Discovering a Subarray within an Array

I have an array called 'array' array = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]; and I am trying to find the index of the subarray [1, 2, 3, 4] However, every time I attempt this, it returns -1 instead of the expected v ...

Using Regular Expressions in Javascript

I have gone through numerous posts with this title, but so far, none of them have addressed my specific query... My requirement is to utilize regex in the following format: "/^ user provided input $/i". The user can include the special regex character * e ...

Current polyfill available for requestAnimationFrame

Recently, I read on that requestAnimationFrame in Chrome 20 now has a new sub-millisecond precision timer. It looks like I need to update my code to accommodate this change. After checking out various polyfills, it seems like they were created before thi ...

What causes certain STL models to appear completely black in a three.js environment?

Screenshot 1 Screenshot 2 Some of my models(STL) have turned completely black while others receive color correctly from the lights. In Screenshot 1 and 2, you can see that the fighter model has color but the miku model appears entirely black. It seems l ...

Ways to verify the nodemon version that is currently installed on your local machine

On my Windows 10 machine, I recently installed nodemon locally in a project and now I'm curious to know which version is installed. Can someone please share the command to check the version of nodemon without needing to install it globally? My aim is ...