Harry Nguyen
Harry Nguyen

Reputation: 191

How to get information about maven dependency from source code?

I'm new to Java and Maven.

I'm following this tutorial about Cucumber in Java but it doesn't mention about Maven dependency such as groupId or artifactId of modules that related to Cucumber.

https://cucumber.netlify.app/docs/guides/browser-automation/

My question is that from information of the code base, how can I get information to insert to pom.xm?

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

Upvotes: 0

Views: 1186

Answers (3)

xomoni
xomoni

Reputation: 121

Any stable released version should be good to use. Example, I see you can use 3.141.59 Like:

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-api -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>3.141.59</version>
</dependency>

Upvotes: 1

Klaus
Klaus

Reputation: 1731

As for the above classes following are the dependencies I use, But there can be compatibility issues with your requirements and versions. Try the below and see if works, else you will have to find it from the maven repository

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>3.141.59</version> <!--Not sure the version-->
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>3.141.59</version> <!--Not sure the version-->
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.141.59</version> <!--Not sure the version-->
    </dependency>

Upvotes: 1

J Fabian Meier
J Fabian Meier

Reputation: 35785

I think you specific question will be answered by looking into the cucumber installation guides.

Your general question ("How to find the Maven dependencies for given imports?") is not truly solvable. You can, of course, take the qualified class names and look them up in https://search.maven.org/, but this will at best narrow down the search, and probably won't tell you which exact versions of the artifacts you should use.

Upvotes: 4

Related Questions