Selenium test on CLI in 5 minutes using Java

This took me two weeks to nail down looking at it here and there.
  1. mkdir stests
  2. cd stests
  3. wget
  4. unzip
  5. mkdir jars
  6. find selenium-2.33.0 -type f -name '*jar' -exec mv -v {} jars \;
  7. rm -rfv selenium-*
  8. mkdir src
  9. vi src/
    1. use below code
  10. mkdir out
  11. javac -d out -cp 'jars/*' src/
    1. ignore "Notes" output
  12. cd out
  13. rm -rfv org
  14. java -cp '../jars/*:.' MyTest

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MyTest  {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        WebElement element = driver.findElement("q"));
        System.out.println("Page title is: " + driver.getTitle());
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
        System.out.println("Page title is: " + driver.getTitle());


  1. The Article on Selenium test on CLI in 5 minutes using Java is nice. It give detail information about it .Thanks for Sharing the information on Selenium test. Software Testing Services


Post a Comment

Popular posts from this blog

Debugging pfsense firewall rules clearly and easily

Direct ssh to a server via proxy using putty/plink on Windows

telnet vs netcat