IntelliJ IDEA java selenium
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package org.openqa.selenium.firefox;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.Platform;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebDriver.Options;
import org.openqa.selenium.WebDriver.Timeouts;
import org.openqa.selenium.firefox.ExtensionConnection;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.NewProfileExtensionConnection;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.internal.Killable;
import org.openqa.selenium.internal.Lock;
import org.openqa.selenium.internal.SocketLock;
import org.openqa.selenium.logging.LocalLogs;
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.logging.NeedsLocalLogs;
import org.openqa.selenium.remote.BeanToJsonConverter;
import org.openqa.selenium.remote.Command;
import org.openqa.selenium.remote.CommandExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.FileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.Response;
import org.openqa.selenium.remote.SessionNotFoundException;
import org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions;
import org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions.RemoteTimeouts;
public class FirefoxDriver extends RemoteWebDriver implements Killable {
public static final String BINARY = "firefox_binary";
public static final String PROFILE = "firefox_profile";
public static final boolean DEFAULT_ENABLE_NATIVE_EVENTS;
/** @deprecated /
@Deprecated
public static final boolean ACCEPT_UNTRUSTED_CERTIFICATES = true;
/* @deprecated */
@Deprecated
public static final boolean ASSUME_UNTRUSTED_ISSUER = true;
protected FirefoxBinary binary;
public FirefoxDriver() {
this((FirefoxBinary)(new FirefoxBinary()), (FirefoxProfile)null);
}
public FirefoxDriver(FirefoxProfile profile) {
this(new FirefoxBinary(), profile);
}
public FirefoxDriver(Capabilities desiredCapabilities) {
this(getBinary(desiredCapabilities), extractProfile(desiredCapabilities, (Capabilities)null), desiredCapabilities);
}
public FirefoxDriver(Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
this(getBinary(desiredCapabilities), extractProfile(desiredCapabilities, requiredCapabilities), desiredCapabilities, requiredCapabilities);
}
private static FirefoxProfile extractProfile(Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
FirefoxProfile profile = null;
Object raw = null;
if(desiredCapabilities != null && desiredCapabilities.getCapability("firefox_profile") != null) {
raw = desiredCapabilities.getCapability("firefox_profile");
}
if(requiredCapabilities != null && requiredCapabilities.getCapability("firefox_profile") != null) {
raw = requiredCapabilities.getCapability("firefox_profile");
}
if(raw != null) {
if(raw instanceof FirefoxProfile) {
profile = (FirefoxProfile)raw;
} else if(raw instanceof String) {
try {
profile = FirefoxProfile.fromJson((String)raw);
} catch (IOException var5) {
throw new WebDriverException(var5);
}
}
}
profile = getProfile(profile);
populateProfile(profile, desiredCapabilities);
populateProfile(profile, requiredCapabilities);
return profile;
}
static void populateProfile(FirefoxProfile profile, Capabilities capabilities) {
if(capabilities != null) {
Boolean nativeEventsEnabled;
if(capabilities.getCapability("webStorageEnabled") != null) {
nativeEventsEnabled = (Boolean)capabilities.getCapability("webStorageEnabled");
profile.setPreference("dom.storage.enabled", nativeEventsEnabled.booleanValue());
}
if(capabilities.getCapability("acceptSslCerts") != null) {
nativeEventsEnabled = (Boolean)capabilities.getCapability("acceptSslCerts");
profile.setAcceptUntrustedCertificates(nativeEventsEnabled.booleanValue());
}
if(capabilities.getCapability("loggingPrefs") != null) {
LoggingPreferences nativeEventsEnabled1 = (LoggingPreferences)capabilities.getCapability("loggingPrefs");
Iterator var3 = nativeEventsEnabled1.getEnabledLogTypes().iterator();
while(var3.hasNext()) {
String logtype = (String)var3.next();
profile.setPreference("webdriver.log." + logtype, nativeEventsEnabled1.getLevel(logtype).intValue());
}
}
if(capabilities.getCapability("nativeEvents") != null) {
nativeEventsEnabled = (Boolean)capabilities.getCapability("nativeEvents");
profile.setEnableNativeEvents(nativeEventsEnabled.booleanValue());
}
}
}
private static FirefoxBinary getBinary(Capabilities capabilities) {
if(capabilities != null && capabilities.getCapability("firefox_binary") != null) {
Object raw = capabilities.getCapability("firefox_binary");
if(raw instanceof FirefoxBinary) {
return (FirefoxBinary)raw;
} else {
File file = new File((String)raw);
return new FirefoxBinary(file);
}
} else {
return new FirefoxBinary();
}
}
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) {
this(binary, profile, DesiredCapabilities.firefox());
}
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, Capabilities capabilities) {
this(binary, profile, capabilities, (Capabilities)null);
}
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
super(new FirefoxDriver.LazyCommandExecutor(binary, profile, null), dropCapabilities(desiredCapabilities, new String[]{"firefox_binary", "firefox_profile"}), dropCapabilities(requiredCapabilities, new String[]{"firefox_binary", "firefox_profile"}));
this.binary = binary;
}
public void setFileDetector(FileDetector detector) {
throw new WebDriverException("Setting the file detector only works on remote webdriver instances obtained via RemoteWebDriver");
}
public void kill() {
this.binary.quit();
}
public Options manage() {
return new RemoteWebDriverOptions(this) {
public Timeouts timeouts() {
return new RemoteTimeouts(this) {
public Timeouts implicitlyWait(long time, TimeUnit unit) {
FirefoxDriver.this.execute("setTimeout", ImmutableMap.of("type", "implicit", "ms", Long.valueOf(TimeUnit.MILLISECONDS.convert(time, unit))));
return this;
}
public Timeouts setScriptTimeout(long time, TimeUnit unit) {
FirefoxDriver.this.execute("setTimeout", ImmutableMap.of("type", "script", "ms", Long.valueOf(TimeUnit.MILLISECONDS.convert(time, unit))));
return this;
}
};
}
};
}
protected void startClient() {
FirefoxDriver.LazyCommandExecutor exe = (FirefoxDriver.LazyCommandExecutor)this.getCommandExecutor();
FirefoxProfile profileToUse = getProfile(exe.profile);
ExtensionConnection connection = this.connectTo(exe.binary, profileToUse, "localhost");
exe.setConnection(connection);
try {
connection.start();
} catch (IOException var5) {
throw new WebDriverException("An error occurred while connecting to Firefox", var5);
}
}
private static FirefoxProfile getProfile(FirefoxProfile profile) {
FirefoxProfile profileToUse = profile;
String suggestedProfile = System.getProperty("webdriver.firefox.profile");
if(profile == null && suggestedProfile != null) {
profileToUse = (new ProfilesIni()).getProfile(suggestedProfile);
if(profileToUse == null) {
throw new WebDriverException(String.format("Firefox profile \'%s\' named in system property \'%s\' not found", new Object[]{suggestedProfile, "webdriver.firefox.profile"}));
}
} else if(profile == null) {
profileToUse = new FirefoxProfile();
}
return profileToUse;
}
protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile profile, String host) {
Lock lock = this.obtainLock(profile);
try {
FirefoxBinary e = binary == null?new FirefoxBinary():binary;
return new NewProfileExtensionConnection(lock, e, profile, host);
} catch (Exception var6) {
throw new WebDriverException(var6);
}
}
protected Lock obtainLock(FirefoxProfile profile) {
return new SocketLock();
}
protected void stopClient() {
((FirefoxDriver.LazyCommandExecutor)this.getCommandExecutor()).quit();
}
private static Capabilities dropCapabilities(Capabilities capabilities, String... keysToRemove) {
if(capabilities == null) {
return new DesiredCapabilities();
} else {
final HashSet toRemove = Sets.newHashSet(keysToRemove);
DesiredCapabilities caps = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate() {
public boolean apply(String key) {
return !toRemove.contains(key);
}
}));
Proxy proxy = Proxy.extractFrom(capabilities);
if(proxy != null) {
caps.setCapability("proxy", (new BeanToJsonConverter()).convert(proxy));
}
return caps;
}
}
public <X> X getScreenshotAs(OutputType<X> target) {
String base64 = this.execute("screenshot").getValue().toString();
return target.convertFromBase64Png(base64);
}
static {
DEFAULT_ENABLE_NATIVE_EVENTS = Platform.getCurrent().is(Platform.WINDOWS);
}
public static class LazyCommandExecutor implements CommandExecutor, NeedsLocalLogs {
private ExtensionConnection connection;
private final FirefoxBinary binary;
private final FirefoxProfile profile;
private LocalLogs logs;
private LazyCommandExecutor(FirefoxBinary binary, FirefoxProfile profile) {
this.logs = LocalLogs.getNullLogger();
this.binary = binary;
this.profile = profile;
}
public void setConnection(ExtensionConnection connection) {
this.connection = connection;
connection.setLocalLogs(this.logs);
}
public void quit() {
if(this.connection != null) {
this.connection.quit();
this.connection = null;
}
if(this.profile != null) {
this.profile.cleanTemporaryModel();
}
}
public Response execute(Command command) throws IOException {
if(this.connection == null) {
if(command.getName().equals("quit")) {
return new Response();
} else {
throw new SessionNotFoundException("The FirefoxDriver cannot be used after quit() was called.");
}
} else {
return this.connection.execute(command);
}
}
public void setLocalLogs(LocalLogs logs) {
this.logs = logs;
if(this.connection != null) {
this.connection.setLocalLogs(logs);
}
}
public URI getAddressOfRemoteServer() {
return this.connection.getAddressOfRemoteServer();
}
}
public static final class SystemProperty {
public static final String BROWSER_BINARY = "webdriver.firefox.bin";
public static final String BROWSER_LOGFILE = "webdriver.firefox.logfile";
public static final String BROWSER_LIBRARY_PATH = "webdriver.firefox.library.path";
public static final String BROWSER_PROFILE = "webdriver.firefox.profile";
public static final String DRIVER_XPI_PROPERTY = "webdriver.firefox.driver";
public static final String DRIVER_USE_MARIONETTE = "webdriver.firefox.marionette";
public SystemProperty() {
}
}
}
IntelliJ IDEA java selenium的更多相关文章
- java selenium (五) 元素定位大全
页面元素定位是自动化中最重要的事情, selenium Webdriver 提供了很多种元素定位的方法. 测试人员应该熟练掌握各种定位方法. 使用最简单,最稳定的定位方法. 阅读目录 自动化测试步骤 ...
- java+Selenium+TestNg搭建自动化测试架构(1)实现代码和数据的分离
1.主要介绍介绍Java+Selenium+POM的自动化测试框架的搭建,第一个首先实现代码和账号URL等信息的分离.第二点支持跨浏览器,通过读取配置文件的方式实现. 1)将账号URL等信息添加在pr ...
- Electorn(桌面应用)自动化测试之Java+selenium实战例子
基于electorn的桌面应用,网上相关资料较少.所有记录一下.使用java+selenium+testng对该类型应用的自动化测试方法. 代码样例 package com.contract.web. ...
- 【java+selenium】网易云音乐刷累计听歌数
背景应该是在去年的时候,刷知乎看到一个问题,大概是说怎么刷网易云音乐个人累计听歌数,然后有一个高赞回答,贴了一段js代码,直接在浏览器console执行就可以了.当时试了下,直接一下子刷了有好几万.悲 ...
- java+selenium的helloworld
在学校上测试课程,接触到自动化管理工具,在加上助教工作需要改作业,所以想着学下selenium这一强大的web自动化工具. 1.lenium官网:http://www.seleniumhq.org/ ...
- java+selenium自动化实践
git+java+selenium+testng +maven+idea 1.git之代码维护(下载.分支切换.上传) 下载命令 "git clone git@github.com:Luna ...
- java selenium webdriver处理JS操作窗口滚动条
未经作者允许,禁止转载!!! java selenium webdriver处理JS操作窗口滚动条 java selenium webdriver处理JS操作窗口滚动条 import org.open ...
- Java+Selenium 3.x 实现Web自动化 - 1.自动化准备
(一)自动化准备 说明:本文主要记录了基于公司现有项目(一个电子商务平台),从0开始实现UI自动化的历程.从准备阶段,部分内容直接省略了基础知识,一切以最终做成自动化项目为目标,难免会有晦涩之处.文章 ...
- Java+selenium自动化测试基础
Java+selenium maven配置 maven的配置,但还需要建立maven的本地库,修改apach-maven的setting.xml http://www.cnblogs.com/haoa ...
随机推荐
- STM32 一个定时器产生4路 独立调频率,占中比可调,脉冲个数可以统计。
实现这个功能,基本原理是利用STM32 的输出比较功能. 1.其它设置就是普通定时器的设置这里开启,四个输出比较中断,和一个更新中断, 更新中断这里不需要开也可以达到目的,我这里开启是做其它的用处的. ...
- Linux基础命令---arch
Arch Arch指令主要用于显示当前主机的硬件结构类型,我们可以看到它输出的结果有:i386.i486.mips.alpha等.此命令的适用范围:RedHat.RHEL.Ubuntu ...
- PHP HTML混写,PHP中把大块HTML文本直接赋值给字符串变量的方法
PHP HTML混写,PHP中把大块HTML文本直接赋值给字符串变量的方法 使用HEREDOC/NOWDOCHEREDOC和NOWDOC是PHP5.3开始支持的一种新特性,它允许在程序中使用一种自定义 ...
- [转载]window.location.href的用法(动态输出跳转)
无论在静态页面还是动态输出页面中window.location.href都是不错的用了跳转的实现方案 javascript中的location.href有很多种用法,主要如下. self.loca ...
- Python框架----cookie和session
一.cookie和session的介绍 cookie不属于http协议范围,由于http协议无法保持状态,但实际情况,我们却又需要“保持状态”,因此cookie就是在这样一个场景下诞生. cookie ...
- 76 道 Oracle Goldengate 面试问题
基础 12c新特性 性能 Troubleshoot 其它 1. Oracle Goldengate 支持部署到哪些拓扑? GoldenGate supports the following topol ...
- Java 代码性能调优“三十六”策
代码优化,一个很重要的课题.可能有些人觉得没用,一些细小的地方有什么好修改的,改与不改对于代码的运行效率有什么影响呢?这个问题我是这么考虑的,就像大海里面的鲸鱼一样,它吃一条小虾米有用吗?没用,但是, ...
- 爬虫之牛掰的scrapy框架
一. Scrapy简介及安装 http://python.jobbole.com/86405/ Scrapy的详细介绍 1.简介 2.安装 1.window上安装: 先 ...
- Could not complete request
Could not complete request com.alibaba.dubbo.rpc.RpcException: Forbid consumer 10.254.1.26 access se ...
- 那些不错的 [ Html5 + CSS3 + Canvas ] 效果!
apng制作工具:http://isparta.github.io/how.html apng制作文章:http://isux.tencent.com/introduction-of-apng.htm ...