//

// 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的更多相关文章

  1. java selenium (五) 元素定位大全

    页面元素定位是自动化中最重要的事情, selenium Webdriver 提供了很多种元素定位的方法.  测试人员应该熟练掌握各种定位方法. 使用最简单,最稳定的定位方法. 阅读目录 自动化测试步骤 ...

  2. java+Selenium+TestNg搭建自动化测试架构(1)实现代码和数据的分离

    1.主要介绍介绍Java+Selenium+POM的自动化测试框架的搭建,第一个首先实现代码和账号URL等信息的分离.第二点支持跨浏览器,通过读取配置文件的方式实现. 1)将账号URL等信息添加在pr ...

  3. Electorn(桌面应用)自动化测试之Java+selenium实战例子

    基于electorn的桌面应用,网上相关资料较少.所有记录一下.使用java+selenium+testng对该类型应用的自动化测试方法. 代码样例 package com.contract.web. ...

  4. 【java+selenium】网易云音乐刷累计听歌数

    背景应该是在去年的时候,刷知乎看到一个问题,大概是说怎么刷网易云音乐个人累计听歌数,然后有一个高赞回答,贴了一段js代码,直接在浏览器console执行就可以了.当时试了下,直接一下子刷了有好几万.悲 ...

  5. java+selenium的helloworld

    在学校上测试课程,接触到自动化管理工具,在加上助教工作需要改作业,所以想着学下selenium这一强大的web自动化工具. 1.lenium官网:http://www.seleniumhq.org/  ...

  6. java+selenium自动化实践

    git+java+selenium+testng +maven+idea 1.git之代码维护(下载.分支切换.上传) 下载命令 "git clone git@github.com:Luna ...

  7. java selenium webdriver处理JS操作窗口滚动条

    未经作者允许,禁止转载!!! java selenium webdriver处理JS操作窗口滚动条 java selenium webdriver处理JS操作窗口滚动条 import org.open ...

  8. Java+Selenium 3.x 实现Web自动化 - 1.自动化准备

    (一)自动化准备 说明:本文主要记录了基于公司现有项目(一个电子商务平台),从0开始实现UI自动化的历程.从准备阶段,部分内容直接省略了基础知识,一切以最终做成自动化项目为目标,难免会有晦涩之处.文章 ...

  9. Java+selenium自动化测试基础

    Java+selenium maven配置 maven的配置,但还需要建立maven的本地库,修改apach-maven的setting.xml http://www.cnblogs.com/haoa ...

随机推荐

  1. golang学习笔记7 使用beego swagger 实现API自动化文档

    golang学习笔记7 使用beego swagger 实现API自动化文档 API 自动化文档 - beego: 简约 & 强大并存的 Go 应用框架https://beego.me/doc ...

  2. AtCoder Beginner Contest 082 A - Round Up the Mean

    题目链接:https://abc082.contest.atcoder.jp/tasks/abc082_a Time limit : 2sec / Memory limit : 256MB Score ...

  3. 大数据自学6-Hue集成环境操作Hbase

    上一章讲过,Hue集成环境是可以直接操作Hbase,但是公司的环境一直报错,虽然也可以透过写代码访问Hbase,但是看到Hue环境中无法访问,还是觉得不爽,因此决定再花些力气找找原因. 找原因要先查L ...

  4. Kattis之旅——Factovisors

    The factorial function, n! is defined thus for n a non-negative integer: 0! = 1 n! = n * (n-1)! (n & ...

  5. AngularJS中angular.min.js:80 Error: [ng:areq] http://errors.angularjs.org/1.2.9/ng/areq

    报出来的时候,出现这种错误,是因为在引入控制器的时候没有引入成功,我遇到这个错误是在因为没有将父控制器引入到子控制器中.

  6. APP端上传图片 - php接口

    $base64="iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAbRJREFUSIntlDFPFF ...

  7. j2ee分布式缓存同步实现方案dlcache

    现成的分布式K/V缓存已经有很多的实现,最主要的比如redis,memcached,couchbase.那为什么我们还要自己去实现呢,在我们解决了分布式系统下大量rpc调用导致的高延时后,我们发现很多 ...

  8. left join加上where条件的困惑

    eft join的困惑:一旦加上where条件,则显示的结果等于inner join将where 换成 and 用where 是先连接然后再筛选   用and 是先筛选再连接 数据库在通过连接两张或多 ...

  9. 20145212罗天晨 WEB基础实践

    实验问题回答 1.什么是表单 表单在网页中主要负责数据采集功能 一个表单有三个基本组成部分: 表单标签 表单域:包含了文本框.密码框.隐藏域.多行文本框.复选框.单选框.下拉选择框和文件上传框等 表单 ...

  10. 尚硅谷面试第一季-10SpringMVC的工作流程

    目录结构: 关键代码: web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xml ...