Created
October 5, 2018 00:07
-
-
Save alexpreynolds/2906b8bf7a2619422a79cca38d8cc44a to your computer and use it in GitHub Desktop.
Selenium Java binding test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.testng.annotations.Test; | |
public class LocalSeleniumTest { | |
public static void main(String[] args) throws IOException, InterruptedException { | |
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver"); | |
ChromeOptions chromeOptions = new ChromeOptions(); | |
chromeOptions.addArguments("--headless"); | |
chromeOptions.addArguments("--no-sandbox"); | |
WebDriver driver = new ChromeDriver(chromeOptions); | |
driver.get("https://www.google.com"); | |
Thread.sleep(1000); | |
if (driver.getPageSource().contains("I'm Feeling Lucky")) { | |
System.out.println("Pass"); | |
} else { | |
System.out.println("Fail"); | |
} | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment