本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxBinary类的典型用法代码示例。如果您正苦于以下问题:Java FirefoxBinary类的具体用法?Java FirefoxBinary怎么用?Java FirefoxBinary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FirefoxBinary类属于org.openqa.selenium.firefox包,在下文中一共展示了FirefoxBinary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDriver
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
@Override
public WebDriver createDriver() throws Exception {
final FirefoxBinary binary = new FirefoxBinary();
if (headless) {
binary.addCommandLineOptions("-headless");
}
final Map<String, String> environmentVariables = new HashMap<>();
if (!headless && xvfbPort != null) {
environmentVariables.put("DISPLAY", ":" + String.valueOf(xvfbPort));
}
final WebDriver driver = new FirefoxDriver(
new GeckoDriverService.Builder()
.usingFirefoxBinary(binary)
.withEnvironment(environmentVariables)
.build()
);
manage(driver);
return driver;
}
示例2: navAdminFirefox17
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
/**
* @author andre.tschirch
*
* Example test method for using specific Firefox version e.g. v17.
*
* Test method for running a successful login and the right presentation of
* the activity state of the admin navigation link, which must be active,
* for browser Firefox.
*/
// @Test
public void navAdminFirefox17() {
ProfilesIni profile = new ProfilesIni();
FirefoxProfile firefoxProfile = profile.getProfile("firefox17");
WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("D:/schatzsuche/firefox17/firefox.exe")), firefoxProfile);
TestBrowser browser = Helpers.testBrowser(driver, 3333);
TestServer server = Helpers.testServer(3333, Helpers.fakeApplication());
TestServer startedServer = null;
try {
server.start();
startedServer = server;
new NavAdminCallbackComposite().invoke(browser);
} catch(Throwable t) {
throw new RuntimeException(t);
} finally {
if(browser != null) {
browser.quit();
}
if(startedServer != null) {
startedServer.stop();
}
}
}
示例3: assumeHavingFirefoxConfigured
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
public static void assumeHavingFirefoxConfigured() {
try {
new FirefoxBinary();
}
catch ( WebDriverException e ) {
if ( e.getMessage().contains("Cannot find firefox binary in PATH") ) {
assumeThat(
"Please define the path to your firefox executable using " +
DefaultFirefoxBinaryProvider.FIREFOX_BINARY_LOCATION_SYSTEM_PROPERTY_KEY +
" system property, or add your firefox executable to the PATH variable! " +
"This is just an assumption to keep our build green.",
System.getProperty(DefaultFirefoxBinaryProvider.FIREFOX_BINARY_LOCATION_SYSTEM_PROPERTY_KEY),
is(notNullValue()));
} else {
throw e;
}
}
}
示例4: Firefox
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
/**
* 本地初始化Firefox浏览器driver
*/
public Firefox() {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("acceptSslCerts", false);
FirefoxBrowserProfile firefoxProfile = new FirefoxBrowserProfile();
String sProfile = firefoxProfile.getDefaultProfile();
if (sProfile.equals("")) {
this.driver = new FirefoxDriver();
} else {
try {
FirefoxProfile profile = new FirefoxProfile(new File(sProfile));
FirefoxBinary firefoxBinary = new FirefoxBinary(new File(firefoxProfile.getFirefoxBinInstallPath()));
profile.setAcceptUntrustedCertificates(false);
this.driver = new FirefoxDriver(firefoxBinary, profile);
} catch (Exception e) {
throw new RuntimeException("Failed to start firefox browser,please check!", e);
}
}
}
示例5: buildDriver
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
@BeforeClass
public static void buildDriver() {
// System.setProperty("webdriver.chrome.driver",
// "/home/csokol/programas/chromedriver/chromedriver");
// driver = new ChromeDriver();
String localTest = System.getenv("LOCAL_TEST");
if ("remote".equals(localTest)) {
driver = ghostDriver();
} else {
FirefoxBinary firefox = new FirefoxBinary();
String display = System.getProperty("DISPLAY", ":0");
firefox.setEnvironmentProperty("DISPLAY", display);
driver = new FirefoxDriver();
}
driver.manage().window().setSize(new Dimension(1280, 800));
waitForFirstBodyPresence();
}
示例6: getWebDriverInstance
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public WebDriver getWebDriverInstance() {
WebDriver retVal = super.getWebDriver();
if (null == retVal) {
FirefoxFeatureProfile bPro = getBrowserProfile();
if (null == bPro) {
retVal = new FirefoxDriver();
} else {
FirefoxBinary binary = new FirefoxBinary();
binary.addCommandLineOptions("-no-remote");
retVal = new FirefoxDriver(binary, bPro.getProfile());
}
setWebDriver(retVal);
}
return retVal;
}
示例7: start
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
@Override
public void start() throws CandybeanException {
String profileName = candybean.config.getValue("browser.firefox.profile", "default");
File ffBinaryPath = new File(candybean.config.getPathValue("browser.firefox.binary"));
if(!ffBinaryPath.exists()){
String error = "Unable to find firefox browser driver from the specified location in the configuration file! \n"
+ "Please add a configuration to the candybean config file for key \"browser.firefox.binary\" that"
+ "indicates the location of the binary.";
logger.severe(error);
throw new CandybeanException(error);
} else {
FirefoxProfile ffProfile = (new ProfilesIni()).getProfile(profileName);
FirefoxBinary ffBinary = new FirefoxBinary(ffBinaryPath);
logger.info("Instantiating Firefox with profile name: "
+ profileName + " and binary path: " + ffBinaryPath);
super.wd = new FirefoxDriver(ffBinary, ffProfile);
super.start(); // requires wd to be instantiated first
}
}
示例8: makeObject
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
@Override
public FirefoxDriver makeObject() throws Exception {
FirefoxBinary ffBinary = new FirefoxBinary();
if (System.getProperty(DISPLAY_PROPERTY_KEY) != null) {
Logger.getLogger(this.getClass()).info("Setting Xvfb display with value " + System.getProperty(DISPLAY_PROPERTY_KEY));
ffBinary.setEnvironmentProperty("DISPLAY", System.getProperty(DISPLAY_PROPERTY_KEY));
}
FirefoxDriver fd = new FirefoxDriver(ffBinary, ProfileFactory.getInstance().getScenarioProfile());
if (this.implicitelyWaitDriverTimeout != null) {
fd.manage().timeouts().implicitlyWait(this.implicitelyWaitDriverTimeout.longValue(), TimeUnit.SECONDS);
}
if (this.pageLoadDriverTimeout != null) {
fd.manage().timeouts().pageLoadTimeout(this.pageLoadDriverTimeout.longValue(), TimeUnit.SECONDS);
}
return fd;
}
示例9: make
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
/**
*
* @param config
* @return A FirefoxDriver.
*/
@Override
public RemoteWebDriver make(HashMap<String, String> config) {
FirefoxBinary ffBinary = new FirefoxBinary();
if (System.getProperty(DISPLAY_PROPERTY) != null) {
ffBinary.setEnvironmentProperty(
DISPLAY_PROPERTY.toUpperCase(),
System.getProperty(DISPLAY_PROPERTY));
} else if (System.getenv(DISPLAY_PROPERTY.toUpperCase()) != null) {
ffBinary.setEnvironmentProperty(
DISPLAY_PROPERTY.toUpperCase(),
System.getenv(DISPLAY_PROPERTY.toUpperCase()));
}
RemoteWebDriver remoteWebDriver = new FirefoxDriver(ffBinary, firefoxProfile);
if (screenHeight != -1 && screenWidth!= -1) {
remoteWebDriver.manage().window().setSize(new Dimension(screenWidth, screenHeight));
}
return remoteWebDriver;
}
示例10: getFFBinary
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
/**
*
* @param filePath
* the binary path location of the firefox app (where it's
* installed)
* @return
*/
private static FirefoxBinary getFFBinary(String filePath) {
File[] possibleLocations = { new File(filePath != null ? filePath : ""),
new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe"),
new File("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"), };
File ffbinary = null;
for (File curr : possibleLocations) {
if (curr.exists()) {
ffbinary = curr;
break;
}
}
if (ffbinary == null) {
throw new RuntimeException(
"Unable to find firefox binary, please ensure that firefox is installed "
+ "on your system. If it is then please determine the path to your firefox.exe and set it as "
+ "binaryPath=<FIREFOX PATH HERE>");
} else {
return new FirefoxBinary(ffbinary);
}
}
示例11: generateFirefoxDriver
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
/**
* Generates a firefox webdriver.
*
* @return
* A firefox webdriver
* @throws TechnicalException
* if an error occured when Webdriver setExecutable to true.
*/
private WebDriver generateFirefoxDriver() throws TechnicalException {
final String pathWebdriver = DriverFactory.getPath(Driver.FIREFOX);
if (!new File(pathWebdriver).setExecutable(true)) {
throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
}
logger.info("Generating Firefox driver ({}) ...", pathWebdriver);
System.setProperty(Driver.FIREFOX.getDriverName(), pathWebdriver);
final FirefoxOptions firefoxOptions = new FirefoxOptions();
final FirefoxBinary firefoxBinary = new FirefoxBinary();
final DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
setLoggingLevel(capabilities);
// Proxy configuration
if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
}
if (Context.isHeadless()) {
firefoxBinary.addCommandLineOptions("--headless");
firefoxOptions.setBinary(firefoxBinary);
}
firefoxOptions.setLogLevel(Level.OFF);
capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, firefoxOptions);
return new FirefoxDriver(capabilities);
}
示例12: constructWebDriver
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
@Override
protected FirefoxDriver constructWebDriver(DesiredCapabilities desiredCapabilities) {
FirefoxBinary firefoxBinary = getFirefoxConfiguration().getFirefoxBinary();
FirefoxProfile profile = getFirefoxConfiguration().getFirefoxProfile();
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
firefoxOptions.setProfile(profile);
return new FirefoxDriver(firefoxOptions);
}
示例13: setUp
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws IOException {
String travisCiFlag = System.getenv().get("TRAVIS");
FirefoxBinary firefoxBinary = "true".equals(travisCiFlag)
? getFirefoxBinaryForTravisCi()
: new FirefoxBinary();
driver = new FirefoxDriver(firefoxBinary, new FirefoxProfile());
}
示例14: getFirefoxBinaryForTravisCi
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
private static FirefoxBinary getFirefoxBinaryForTravisCi() throws IOException {
String firefoxPath = getFirefoxPath();
Logger staticLog = LoggerFactory.getLogger(UseNewFirefoxOnTravisTest.class);
staticLog.info("Firefox path: " + firefoxPath);
return new FirefoxBinary(new File(firefoxPath));
}
示例15: getFirefoxDriver
import org.openqa.selenium.firefox.FirefoxBinary; //导入依赖的package包/类
private AetFirefoxDriver getFirefoxDriver(FirefoxProfile fp, DesiredCapabilities capabilities)
throws IOException {
AetFirefoxDriver driver;
if (StringUtils.isBlank(path)) {
driver = new AetFirefoxDriver(capabilities);
} else {
FirefoxBinary binary = new FirefoxBinary(new File(path));
driver = new AetFirefoxDriver(binary, fp, capabilities);
}
driver.manage().timeouts().pageLoadTimeout(5L, TimeUnit.MINUTES);
return driver;
}