Selenium

Guide by Sebastiaan Baan

Selenium is a browser automation tool. It has the support of some of the largest browser vendors and is widely used by companies to automate day-to-day tasks.

🚧

Notice

Selenium does not support the standard username:password authentication, so you will need to have whitelisted IP to use this automation tool.

1. Choosing your language

Selenium officially supports the following programming languages:

  • Java
  • C#
  • Ruby
  • Python
  • Javascript (Node)

To use this tool, it's recommended to have experience with at least one of these programming languages or have programming background in general.

2. Choosing your WebDriver

Selenium offers a variety of WebDrivers to perform tests. To continue development with this tool, you will need to use at least one of the available WebDrivers.

You can find the whole list of available WebDrivers here. However, Smartproxy currently provides tutorials for the following two:

3. Getting in to the code

Smartproxy offers code examples for all five programming languages officially supported by Selenium.

Please note that while syntax and code layout may differ, the principle of the proxy setup is relatively similar in all programming languages.

To download our code example for your preferred programming language and WebDriver, take a look at the tables below:

Google Chrome Driver

curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/java/chrome/example.java > example.java
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/csharp/chrome/example.cs > example.cs
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/ruby/chrome/example.rb > example.rb
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/python/selenium_python.py > selenium_python.py
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/nodejs/chrome/example.js > example.js

Mozilla GeckoDriver

curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/java/firefox/example.java > example.java
curl https://raw.githubusercontent.com/Smartproxy/Smartproxy/master/selenium/csharp/firefox/example.cs > example.cs
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/ruby/firefox/example.rb > example.rb
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/python/selenium_python.py > selenium_python.py
curl https://raw.githubusercontent.com/Smartproxy/Selenium/master/nodejs/firefox/example.js > example.js

You can copy and run all of the commands from the table above in your Terminal/Command Prompt window.

4. Configuring the connection

To configure your preferred endpoint in our code examples, please use gate.smartproxy.com:7000 line within the punctuation marks ' '. Different languages will have this line placed and formatted differently.

Take a look at the reference table below:

String ProxyServer = "gate.smartproxy.com";
int ProxyPort = 7000;
HttpProxy = "gate.smartproxy.com:7000"
proxy = Selenium::WebDriver::Proxy.new(http: "gate.smartproxy.com:7000")
HOSTNAME = 'gate.smartproxy.com'
PORT = '7000'
let addr = 'gate.smartproxy.com:7000'

5. Additional information

Please note that the examples provided are just for proxy setup reference.

If you need more help with the setup, refer to our Github page for language-specific setups: