Welcome to the Question and Answer site for Software Testing Professionals

You can get your queries resolved from Software Testing Professionals.

Ask a Question

Get answers and give answers to questions from other members.

View All Questions

Get votes and earn points to build your reputation in community.

View Hot Questions

what are the languages supported by selenium webdriver?

Open 1 Answers 95 Views
0 1
what are the languages supported by selenium webdriver?

1 Answer


Selenium WebDriver supports below languages.

  • C#
  • Haskell
  • Java
  • JavaScript
  • Objective-C
  • Perl
  • PHP
  • Python
  • R
  • Ruby

Here is the sample code from each language I have worked with.

C# sample:

using System.IO;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace WebDriverExample
    class Program
        static void Main(string[] args)
            // Initialize the Chrome Driver
            using (var driver = new ChromeDriver())
                // Go to the home page
                // Take a screenshot and save it into screen.png
                driver.GetScreenshot().SaveAsFile(@"screen.png", ImageFormat.Png);
Java sample:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.net.URL;
public class WebDriverExample {
  public static void main(String[] args) throws Exception {
    WebDriver driver = new FirefoxDriver();
    System.out.println("title of page is: " + driver.getTitle());
Javascript example:
var webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until;
var driver = new webdriver.Builder()
driver.wait(until.titleIs('Mayur Shah), 1000);
Perl sample:
use WWW::Selenium;
my $sel = WWW::Selenium->new( host => "localhost",
                                  port => 4444,
                                  browser => "*iexplore",
                                  browser_url => "http://mayurshah.in",
print $sel->get_title;
PHP Sample:
class GitHubTest extends PHPUnit_Framework_TestCase {
    protected $webDriver;
public function setUp()
        $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox');
        $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities);
    protected $url = 'https://mayurshah.in';
    public function testGitHubHome()
        $this->assertContains('Mayur', $this->webDriver->getTitle());
Python sample
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
assert "Mayur Shah" not in driver.page_source
Ruby Sample:
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://mayurshah.in"


Hope that helps!

answered by (192 points)

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

We have resolved 1.2k+ Software Testing queries!

Software Testing Board Weekly update

We will send you handpicked questions that you would love to answer.

View previous campaigns.

Top Contributors