use of org.openqa.selenium.firefox.FirefoxDriver in project webpieces by deanhiller.
the class Selenium2Example method main.
public static void main(String[] args) {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Alternatively the same thing can be done like this
// driver.navigate().to("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
// Should see: "cheese! - Google Search"
System.out.println("Page title is: " + driver.getTitle());
//Close the browser
driver.quit();
}
use of org.openqa.selenium.firefox.FirefoxDriver in project iTest by e-government-ua.
the class SetupAndTeardown method SetUp.
@BeforeMethod(alwaysRun = true)
public void SetUp() throws IOException {
// driver = new FirefoxDriver(profileFF);
if (null == driver) {
/**
* ******* Для локального тестирования установить switch ("chrome")
* для jenkins switch ("firefox") **********
*/
switch("firefox") {
case "firefox":
/**
* ******* Закоментить для для запуска на своем профиле и
* откоментить для запуска на дефолтном **********
*/
//Save the path of the XPI files as per your saved location
String cryptopluginPath = "src/test/resources/files/cryptoplugin_ext_id@privatbank.ua.xpi";
File cryptoplugin = new File(cryptopluginPath);
FirefoxProfile profile = new FirefoxProfile();
// profile.addExtension(cryptoplugin);
profile.setEnableNativeEvents(true);
profile.setAcceptUntrustedCertificates(true);
// profile.addExtension(cryptoplugin);
/**
* ******* Раскомментить для запуска на своем профиле и
* закоментить для дефолтного **********
*/
// ProfilesIni allProfiles = new ProfilesIni();
// FirefoxProfile profile = allProfiles.getProfile("default");
profile.setPreference("extensions.cryptoplugin_ext_id@privatbank.currentVersion", "9.9.9");
profile.setEnableNativeEvents(true);
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
profile.setPreference("javascript.enabled", true);
profile.setPreference("geo.enabled", false);
profile.setPreference("extensions.cryptoplugin_ext_id@privatbank.ua.currentVersion", "999.999.999");
capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setCapability("unexpectedAlertBehaviour", "ignore");
System.out.println("Tests will be run (or rerun) in Firefox with custom profile...");
driver = WebDriverFactory.getDriver(capabilities);
/**
* ******* Для локального тестирования **********
*/
// case "chrome":
// System.setProperty("webdriver.chrome.driver", "src\\test\\resources\\files\\chromedriver.exe");
// capabilities = DesiredCapabilities.chrome();
// options = new ChromeOptions();
// System.out.println("Tests will be run (or rerun) in Chrome with custom profile...");
// break;
// default:
this.driver = new FirefoxDriver();
System.out.println("Tests will be run (or rerun) in Firefox...");
break;
}
driver = WebDriverFactory.getDriver(capabilities);
this.driver.manage().timeouts().implicitlyWait(CV.implicitTimeWait, TimeUnit.SECONDS);
this.driver.manage().window().maximize();
this.driver.manage().deleteAllCookies();
}
}
Aggregations