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 ...
随机推荐
- 转:wcf大文件传输解决之道(1)
首先声明,文章思路源于MSDN中徐长龙老师的课程整理,加上自己的一些心得体会,先总结如下: 在应对与大文件传输的情况下,因为wcf默认采用的是缓存加载对象,也就是说将文件包一次性接受至缓存中,然后生成 ...
- 关于字符串split一些用法
split方法在大数据开发中的多用于日志解析及字段key值分割,最近需求中碰到一个问题在 无论怎么分割都会出现数组下标越界问题, 由于前台在sdk中多加了几个字段(测试数据很少,大多为空) ,需要我们 ...
- java之异常统一处理
spring-mvc.xml <!-- aop --> <aop:aspectj-autoproxy/> <beans:bean id="controllerA ...
- runltp<p-pan
- intelliJ IDEA之使用svn或git管理代码
intelliJ IDEA之使用svn管理代码 1.VCS—>import into Version Control—>Share Project(Subversion) 2.点击+ ...
- css背景样式background
background用来定义html元素的背景效果 background-color:定义元素的背景颜色,背景的颜色值通常有三种定义方法 1.十六进制方式,如"#ff0000" 2 ...
- python的zipfile、tarfile模块
zipfile.tarfile的用法 先占个位置,后续再实际操作和补充 参考 https://www.cnblogs.com/MnCu8261/p/5494807.html
- 08: MySQL慢查询
1.1 寻找慢查询 定义:我们将超过指定时间的SQL语句查询称为“慢查询”. 1.在mysql日志中开启慢查询日志 1. 修改配置文件 在 my.ini 增加几行: 主要是慢查询的定义时间(超 ...
- python简说(十五)MD5加密
def my_md5(s): news = str(s).encode() m = hashlib.md5(news) return m.hexdigest()
- Django项目的创建与介绍.应用的创建与介绍.启动项目.pycharm创建启动项目.生命周期.三件套.静态文件.请求及数据.配置Mysql完成数据迁移.单表ORM记录的增删改查
一.Django项目的创建与介绍 ''' 安装Django #在cmd中输入pip3 #出现这个错误Fatal error in launcher: Unable to create process ...