Skip to content

Instantly share code, notes, and snippets.

@jarib
Forked from anonymous/gist:1095693
Created July 20, 2011 19:18
Show Gist options
  • Save jarib/1095695 to your computer and use it in GitHub Desktop.
Save jarib/1095695 to your computer and use it in GitHub Desktop.
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FFLinux {
public static void main(String[] args) {
WebDriver ff = new FirefoxDriver();
ff.get("http://www.domain.com");
ff.findElement(By.linkText("Login")).click();
ff.findElement(By.xpath("//div[@id = 'idSignIn']")).click();
ff.findElement(By.id("logonId")).sendKeys("user");
ff.findElement(By.id("logonPassword")).sendKeys("pass");
ff.findElement(By.id("Sign_In_and_Continue")).click();
if(isElementPresent(driver, By.id("search_field"))) {
System.out.println("found");
} else {
System.out.println("not found");
}
ff.quit();
}
private static boolean isElementPresent(WebDriver driver, By locator) {
try {
driver.findElement(locator);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment