| title | Install a Selenium library | |||
|---|---|---|---|---|
| linkTitle | Install Library | |||
| weight | 2 | |||
| description | Setting up the Selenium library for your favourite programming language. | |||
| aliases |
|
First you need to install the Selenium bindings for your automation project. The installation process for libraries depends on the language you choose to use. Make sure you check the Selenium downloads page to make sure you are using the latest version.
{{< tabpane text=true >}} {{% tab header="Java" %}} View the minimum supported Java version here.
Installation of Selenium libraries for Java is accomplished using a build tool.
Specify the dependencies in the project's pom.xml file:
{{< gh-codeblock path="/examples/java/pom.xml#L35-L38" >}}
Specify the dependency in the project build.gradle file as testImplementation:
{{< gh-codeblock path="/examples/java/build.gradle#L13-L14" >}}
{{% /tab %}} {{% tab header="Python" %}} The minimum supported Python version for each Selenium version can be found in "Supported Python Versions" on PyPi.
There are a couple different ways to install Selenium.
pip install seleniumAlternatively you can download the PyPI Built Distribution (selenium-x.x.x.-py3-none-any.whl) and install it using pip:
pip install selenium-x.x.x.-py3-none-any.whlTo use it in a project, add it to the requirements.txt file:
{{< gh-codeblock path="/examples/python/requirements.txt#L1" >}}
{{% /tab %}} {{% tab header="CSharp" %}} A list of all supported frameworks for each version of Selenium is available on Nuget
There are a few options for installing Selenium.
Install-Package Selenium.WebDriverdotnet add package Selenium.WebDriverin the project's csproj file, specify the dependency as a PackageReference in ItemGroup:
{{< gh-codeblock language="xml" path="/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj#L14" >}}
Further items of note for using Visual Studio Code (vscode) and C#
Install the compatible .NET SDK as per the section above.
Also install the vscode extensions (Ctrl-Shift-X) for C# and NuGet.
Follow the instruction here
to create and run the "Hello World" console project using C#.
You may also create a NUnit starter project using the command line dotnet new NUnit.
Make sure the file %appdata%\NuGet\nuget.config is configured properly as some developers reported that it will be empty due to some issues.
If nuget.config is empty, or not configured properly, then .NET builds will fail for Selenium Projects.
Add the following section to the file nuget.config if it is empty:
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
...
For more info about nuget.config click here.
You may have to customize nuget.config to meet you needs.
Now, go back to vscode, press Ctrl-Shift-P, and type "NuGet Add Package", and enter the required Selenium packages such as Selenium.WebDriver.
Press Enter and select the version.
Now you can use the examples in the documentation related to C# with vscode.
{{% /tab %}} {{% tab header="Ruby" %}} You can see the minimum required version of Ruby for any given Selenium version on rubygems.org
Selenium can be installed two different ways.
gem install selenium-webdriver{{< gh-codeblock language="ruby" path="/examples/ruby/Gemfile#L10" >}}
{{% /tab %}}
{{% tab header="JavaScript" %}}
You can find the minimum required version of Node for any given version of Selenium in the
Node Support Policy section on npmjs
Selenium is typically installed using npm.
npm install selenium-webdriverIn your project's package.json, add requirement to dependencies:
{{< gh-codeblock path="/examples/javascript/package.json#L14" >}}
{{% /tab %}} {{< tab header="Kotlin" >}} Use the Java bindings for Kotlin. {{< /tab >}} {{< /tabpane >}}
[Create your first Selenium script]({{< ref "first_script.md" >}})