ChromeDriver issues implementing in java with maven

ChromeDriver issues implementing in java with maven



I cant seem to get a headless chromedriver setup in java working.



I am running Java8 on Ubuntu 18.04 with netbeans 8.2



Is it possible I am getting the error below because I don't have maven installed correctly?



I have made the chromedriver executable and added the path using:


String chromeDriverPath = "/home/bob/NetBeansProjects/ScrapeLetGo/src/main/resources/chromedriver.exe";
System.setProperty("webdriver.chrome.driver", chromeDriverPath);



I have added dependencies and more dependencies to POM.XML:


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>ScrapeLetGo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>



<dependency>
<groupId>org.openqa.selenium.core</groupId>
<artifactId>scrapeletgo</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>$project.basedir/src/main/resources/webdriver-common-0.9.7376.jar</systemPath>
</dependency>

<dependency>
<groupId>org.openqa.selenium.core</groupId>
<artifactId>scrapeletgo</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/home/bob/NetBeansProjects/ScrapeLetGo/src/main/resources/selenium-chrome-driver-2.26.0.jar</systemPath>


</dependency>



<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.14.0</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>



However, when I go to instantiate with:


ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu", "--window-size=1920,1200","--ignore-certificate-errors", "--silent");
WebDriver driver = new ChromeDriver(options);
driver.get("https://us.letgo.com/en?searchTerm=dell%20optiplex");



I get errors and/or it doesn't compile.



Here are some errors I get:


Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1



and also this


ClassNotFoundException: org.openqa.selenium.HasInputDevices





You did not pass ChromeOptions in ChromeDriver constructor.
– silver
Sep 2 at 17:35





Ok I updated it to include options being passed in. I still get the same errors however
– Daveyman123
Sep 2 at 17:39





Why do you have multiple versions of selenium-java? Keeping your pom.xml clean of redundant dependencies comes first. You may want to read on Transient Dependencies in Maven so you understand what it does before attempting to use it. You also need to point to the chromedriver binary (.exe) not just to the folder where it's at.
– silver
Sep 2 at 17:48


selenium-java


pom.xml


.exe





It would seem that cleaning up my POM.XML helped
– Daveyman123
Sep 2 at 19:01





Good. What you just experienced is called "dependency hell". You should only keep the things you need in the pom.xml. Maven also automatically downloads dependencies of dependencies. For example, if you put in selenium-server, no need to put selenium-java because server depends on java. Maven will automatically download. This is called transient dependencies. The Maven Repo site shows what transient dependencies a dependency has.
– silver
Sep 3 at 3:04


selenium-server


selenium-java






Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)