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 ...
随机推荐
- Linux基础命令---join
join 找出两个文件中相同的字段,根据相同字段合并两个文件,将合并结果显示到标准输出. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora ...
- 转:获得数据库自增长ID(ACCESS)与(SQLSERVER)
转载自:http://www.cnblogs.com/chinahnzl/articles/968649.html 问题CSDN 里面不时有初学者疑惑:如何获取自增长列(标识列)的ID,并写入另一张表 ...
- Javaweb笔记—03(BS及分页的业务流程)
DAO部分:中间层声明该有的变量 pagerBook pageData sumRow sumPage求出总的记录数id唯一标识:select count(id) as rowsum from book ...
- MyEclipse如何配置Struts2源码的框架压缩包
1.MyEclipse如何配置Struts2源码的框架压缩包 如本机的Struts2框架压缩包路径为:D:\MyEclipseUserLibraries\struts\struts-2.3.15.3- ...
- c语言cgi笔记
直接输出接收的数据 #include <stdio.h>#include <stdlib.h>main(){int i,n;printf ("Content-type ...
- 【题解】Luogu P1972 [SDOI2009]HH的项链
原题传送门 莫队入门题 我博客里对莫队的介绍 很多人说这题卡莫队,但窝随便写了一个程序就过了qaq(虽说开了氧化) 我们在排序询问时,普通是这样qaq inline bool cmp(register ...
- opencv学习之路(11)、图像几何变换
一.图像缩放 #include<opencv2/opencv.hpp> using namespace cv; void main(){ Mat src=imread("E:// ...
- php 输出缓存,每秒打印一个数字
<?php set_time_limit(0); //以上三行不加上nginx下不执行,一次性显示出来 header('Content-Type: text/event-stream'); // ...
- KNN(K-Nearest Neighbor)介绍
KNN(K-Nearest Neighbor)介绍 原文地址:https://www.cnblogs.com/nucdy/p/6349172.html Wikipedia上的 KNN词条 中有一个比较 ...
- python --- 22 初始模块 random time collections functools
一 .初始模块 1.从⼩到⼤的顺序: ⼀条代码 < 语句块 < 代码块(函数, 类) < 模块 2.引入模块的方式 ① import 模块 ② from 模块 im ...