本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxOptions类的典型用法代码示例。如果您正苦于以下问题:Java FirefoxOptions类的具体用法?Java FirefoxOptions怎么用?Java FirefoxOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FirefoxOptions类属于org.openqa.selenium.firefox包,在下文中一共展示了FirefoxOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFirefoxOptions
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("testClassProvider")
@SuppressWarnings("unchecked")
void testFirefoxOptions(Class<?> testClass) throws Exception {
Parameter parameter = testClass
.getMethod("webrtcTest", FirefoxDriver.class)
.getParameters()[0];
Optional<Object> testInstance = Optional.of(testClass.newInstance());
FirefoxOptions firefoxOptions = (FirefoxOptions) annotationsReader
.getOptions(parameter, testInstance);
Map<String, Map<String, Boolean>> options = (Map<String, Map<String, Boolean>>) firefoxOptions
.asMap().get(FIREFOX_OPTIONS);
assertTrue(options.get("prefs")
.get("media.navigator.permission.disabled"));
assertTrue(options.get("prefs").get("media.navigator.streams.fake"));
}
示例2: settingBrowserSize
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Test
public void settingBrowserSize() {
// given
WebDriverProperties properties = new WebDriverProperties();
properties.setProperty("browserSize", "1690x1000");
// when
Capabilities convertedCapabilities = firefoxCapabilitiesConverter.convert(properties);
// then
// expected safari options
FirefoxOptions expectedFirefoxOptions = new FirefoxOptions();
expectedFirefoxOptions.setCapability(CAPABILITY_AUTOCLOSE, false);
expectedFirefoxOptions.setCapability(CAPABILITY_BROWSER_SIZE, "1690x1000");
assertThat(convertedCapabilities.asMap()).isEqualTo(expectedFirefoxOptions.asMap());
}
示例3: resolve
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Override
public void resolve() {
try {
Optional<Object> testInstance = context.getTestInstance();
Optional<Capabilities> capabilities = annotationsReader
.getCapabilities(parameter, testInstance);
FirefoxOptions firefoxOptions = (FirefoxOptions) getOptions(
parameter, testInstance);
if (capabilities.isPresent()) {
firefoxOptions.merge(capabilities.get());
}
object = new FirefoxDriver(firefoxOptions);
} catch (Exception e) {
handleException(e);
}
}
示例4: getFirefoxOptions
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
private FirefoxOptions getFirefoxOptions() throws IOException {
String driverPath = getProperty("browser.driver.path");
if (!"".equals(driverPath)) {
System.setProperty("webdriver.gecko.driver", driverPath);
}
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
FirefoxProfile profile = getProfile();
if (profile == null) {
String version = getProperty("browser.version");
if (version != null) {
options.setCapability("version", version);
}
} else {
options.setProfile(profile);
}
return options;
}
示例5: configuration
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Override
public Capabilities configuration(final XmlConfig config) {
final FirefoxOptions options = new FirefoxOptions();
options.setCapability("enableVNC", true);
options.setCapability("name", config.getTestName());
options.setCapability("screenResolution", "1280x1024x24");
return merge(config, options);
}
示例6: 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);
}
示例7: createOptions
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
protected FirefoxOptions createOptions()
{
FirefoxOptions options = new FirefoxOptions();
options.setProfile(createProfile());
return options;
}
示例8: convert
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Override
public Capabilities convert(WebDriverProperties properties) {
FirefoxOptions firefoxOptions = new FirefoxOptions();
// general options for logging purpose
firefoxOptions.setCapability(CAPABILITY_AUTOCLOSE, properties.isAutoClose());
addToFirefoxOptionsIfNoEmptyValue(firefoxOptions, CAPABILITY_DRIVER_VERSION, properties.getDriverVersion());
addToFirefoxOptionsIfNoEmptyValue(firefoxOptions, CAPABILITY_BROWSER_SIZE, properties.getBrowserSize());
return firefoxOptions;
}
示例9: getDriver
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
public static WebDriver getDriver() {
if (instance == null) {
instance = new DriverManager();
instance.driver = new FirefoxDriver(new FirefoxOptions().setLegacy(true));
}
return instance.driver;
}
示例10: setUp
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Before
public void setUp() {
System.setProperty("webdriver.gecko.driver", "C:\\Program Files\\Java\\geckodriver.exe");
driver = new FirefoxDriver(new FirefoxOptions().setLegacy(true));
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
wait = new WebDriverWait(driver, 10);
}
示例11: 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);
}
示例12: 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);
}
示例13: allocateFirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@NotNull private static WebDriver allocateFirefoxDriver(Locale lang) throws IOException {
FirefoxOptions fo = new FirefoxOptions();
////-- Set the XDG_CONFIG_HOME envvar; this is used by fontconfig as one of its locations
//File dir = createFontConfigFile();
//FirefoxBinary ffb = new FirefoxBinary();
//ffb.setEnvironmentProperty("XDG_CONFIG_HOME", dir.getParentFile().getAbsolutePath());
//FirefoxOptions ffo = new FirefoxOptions(getFirefoxCapabilities(lang));
//ffo.setBinary(ffb);
//FirefoxDriver wd = new FirefoxDriver(ffo);
replaceDotFonts();
FirefoxDriver wd = new FirefoxDriver(getFirefoxCapabilities(lang));
String browserName = wd.getCapabilities().getBrowserName();
String version = wd.getCapabilities().getVersion();
System.out.println("wd: allocated " + browserName + " " + version);
return wd;
}
示例14: setupTest
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Before
public void setupTest() {
FirefoxOptions options = new FirefoxOptions();
// This flag avoids granting the access to the camera
options.addPreference("media.navigator.permission.disabled", true);
// This flag force to use fake user media (synthetic video of multiple
// color)
options.addPreference("media.navigator.streams.fake", true);
driver = new FirefoxDriver(options);
}
示例15: VaadinLocaleTest
import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
public VaadinLocaleTest(String language, String expectedLanuage) {
this.expectedLanguage = expectedLanuage;
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("intl.accept_languages", language);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(profile);
WebDriver webDriver = new FirefoxDriver(firefoxOptions);
startBrowser(webDriver);
}