本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxOptions.setBinary方法的典型用法代码示例。如果您正苦于以下问题:Java FirefoxOptions.setBinary方法的具体用法?Java FirefoxOptions.setBinary怎么用?Java FirefoxOptions.setBinary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.firefox.FirefoxOptions
的用法示例。
在下文中一共展示了FirefoxOptions.setBinary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的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);
}
示例2: constructWebDriver
import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的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);
}
示例3: setUp
import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception
{
FirefoxOptions options = new FirefoxOptions();
options.setBinary("/usr/bin/firefox");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", false);
capabilities.setCapability("moz:firefoxOptions", options);
driver = new FirefoxDriver(capabilities);
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
示例4: getOptions
import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的package包/类
@Override
public MutableCapabilities getOptions(Parameter parameter,
Optional<Object> testInstance)
throws IOException, IllegalAccessException {
FirefoxOptions firefoxOptions = new FirefoxOptions();
// @Arguments
Arguments arguments = parameter.getAnnotation(Arguments.class);
if (arguments != null) {
stream(arguments.value()).forEach(firefoxOptions::addArguments);
}
// @Extensions
Extensions extensions = parameter.getAnnotation(Extensions.class);
if (extensions != null) {
for (String extension : extensions.value()) {
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(getExtension(extension));
firefoxOptions.setProfile(firefoxProfile);
}
}
// @Binary
Binary binary = parameter.getAnnotation(Binary.class);
if (binary != null) {
firefoxOptions.setBinary(binary.value());
}
// @Preferences
managePreferences(parameter, firefoxOptions);
// @Options
Object optionsFromAnnotatedField = annotationsReader
.getOptionsFromAnnotatedField(testInstance, Options.class);
if (optionsFromAnnotatedField != null) {
firefoxOptions = ((FirefoxOptions) optionsFromAnnotatedField)
.merge(firefoxOptions);
}
return firefoxOptions;
}