首先这次使用的webDriver for Firefox的

由于项目的原因,需要在测试的时候加载Firebug和使用vpn,加载代理

Firefox 加载代理,可以从FF菜单上看,代理分为好几种

我这里使用的是type 为2 的情况

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 2);
profile.setPreference("network.proxy.autoconfig_url", "http://proxy.myweb.com:8083"); //自动代理配置
WebDriver driver = new FirefoxDriver(profile);

如果type 为1 ,需要这么设置

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", "proxy.domain.example.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.domain.example.com");
profile.setPreference("network.proxy.ssl_port", 8080);
profile.setPreference("network.proxy.ftp", "proxy.domain.example.com");
profile.setPreference("network.proxy.ftp_port", 8080);
profile.setPreference("network.proxy.socks", "proxy.domain.example.com");
profile.setPreference("network.proxy.socks_port", 8080);
WebDriver driver = new FirefoxDriver(profile);
public class sfLogin {
static String company="autoPM2CandU";
static String user="athompson";
static String password="pwd"; public static void main(String[] args) {
// TODO Auto-generated method stub
WindowsUtils.tryToKillByName("firefox.exe");
WindowsUtils.getProgramFilesPath();
WebDriver driver=DriverFactory.getFirefoxDriver();
driver.get("https://qaautocand.successfactors.com/login");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS); WebElement comp=driver.findElement(By.xpath("//*[@id='company']"));
Actions actions =new Actions(driver);
actions.sendKeys(Keys.F12).perform();//.keyUp(Keys.F12)
WebElement username=driver.findElement(By.xpath("//*[@id='username']"));
WebElement passwordHints=driver.findElement(By.xpath("//*[@id='passwordHints']")); passwordHints.click();
WebElement pw=driver.findElement(By.xpath("//*[@id='password']")); WebElement login=driver.findElement(By.xpath("//*[@id='loginSubmitBtn']"));
comp.sendKeys(company);
username.sendKeys(user);
passwordHints.click();
pw.sendKeys(password);
login.submit(); WebElement home=driver.findElement(By.xpath("//*[@id='8:label']")); actions.moveToElement(home).click().build().perform();
WebElement performance=driver.findElement(By.xpath("//*[@id='10:2']"));
performance.click(); WebElement endBox=driver.findElement(By.xpath("//*[@id='tablist']/tbody/tr[2]/td/div/div/div/table/tbody/tr[3]/td[2]/a")); endBox.click(); WebElement auditTrailButton =driver.findElement(By.xpath("//*[@id='form_list_table']/tbody/tr/td[10]/a[2]/img"));
auditTrailButton.click(); WebElement action =driver.findElement(By.xpath("//*[@id='contentBodyTable']/tbody/tr[2]/td/div[2]/div/div[2]/div/div/div[2]/div/table/tbody/tr/td/table[2]/tbody/tr[2]/td/table/tbody/tr[4]/td/table/tbody/tr[4]/td[9]")); System.out.println(action.getText()); } }

如果需要加载firebug

    File file=new File("d:\\firebug-2.0.4-fx.xpi");//设置Firebug路径
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", "proxy.domain.example.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.domain.example.com");
profile.setPreference("network.proxy.ssl_port", 8080);
profile.setPreference("network.proxy.ftp", "proxy.domain.example.com");
profile.setPreference("network.proxy.ftp_port", 8080);
profile.setPreference("network.proxy.socks", "proxy.domain.example.com");
profile.setPreference("network.proxy.socks_port", 8080); try {
profile.addExtension(file);
profile.setPreference("extensions.firebug.currentVersion", "2.0.4");//设置firebug 版本
} catch (IOException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
} WebDriver driver = new FirefoxDriver(profile);
return driver;

如果需要在运行时候firebug执行

Actions actions =new Actions(driver);
actions.sendKeys(Keys.F12).perform();//使用F12调出firebug

扩展,为什么这么设置

你可以使用about:config 在Firefox里边看看

Selenium FF WebDriver 加载firebug 和设置代理的更多相关文章

  1. Selenium FF WebDriver运行时开启firebug的2种方式

    上一次我实测FF webdriver 加载firefoxhttp://www.cnblogs.com/tobecrazy/p/3997375.html 那么问题就来了,既然能加载firebug能否在运 ...

  2. js不需要知道图片宽高的懒加载方法(经过实际测试,不加宽高仍然是无法正常加载的,设置height:auto,height:100%,仍然显示高度为0)

    js不需要知道图片宽高的懒加载方法 懒加载是如何实现的? - 简书https://www.jianshu.com/p/e86c61468285找到一个不需要知道图片宽高的懒加载方法了(经过实际测试,不 ...

  3. selenium2入门 用selenium安装、加载、启用插件(一)

    一:下载 下载地址是:http://docs.seleniumhq.org/download/

  4. selenium2 用selenium安装、加载、启用插件(一)

    一:下载 下载地址是:http://docs.seleniumhq.org/download/

  5. selenium自动化之加载浏览器的配置文件

    做seleniumUI自动化关于选用哪个浏览器方面,对于我来说,火狐浏览器只是用于定位元素,因为有firebug(注意高版本的火狐已经安装不了这个插件了),而真正执行自动化脚本用的是谷歌,感觉谷歌的速 ...

  6. selenium 等待页面加载完成

    一.隐形加载等待: file:///C:/Users/leixiaoj/Desktop/test.html 该页面负责创建一个div <html> <head> <tit ...

  7. Selenium WebDriver- 指定页面加载时间

    #encoding=utf-8 import unittest import time from selenium import webdriver from selenium.webdriver i ...

  8. Selenium 的页面加载以及几种等待的问题

    1. PageLoadStrategy : 当调用driver.get("https://xxxx.xxx.xxx")来访问某页面时,get方法通常会阻塞浏览器直到页面完全加载后才 ...

  9. python3 selenium 超时停止加载,并且捕捉异常, 进行下一步【亲测有效】

    from selenium import webdriver import os import re class GetPage: def __init__(self, url_path): self ...

随机推荐

  1. C++ 数组array与vector的比较

    转:http://blog.csdn.net/yukin_xue/article/details/7391897 1. array 定义的时候必须定义数组的元素个数;而vector 不需要: 且只能包 ...

  2. java-w3c.document生成xml文件

    案例 /** * 创建和写入xml * @param xmlrootname * @param waitConverList */ private void createAndWriterXML(St ...

  3. 页面局部跳转(iframe)

    <script type="text/javascript"> function show() { document.getElementById("ff&q ...

  4. 【poj2409】 Let it Bead

    http://poj.org/problem?id=2409 (题目链接) 题意 一个n个珠子的项链,每个珠子可以被染成t种颜色.项链可以翻转和旋转,问不同的染色方案数. Solution Pólya ...

  5. 魅族mx4 pro连电脑,adb无法获取devices信息解决

    根据 flyme 的文档: K:\MX4 USB Reference Manual\简体\MX4_ADB_参考说明书.txt 操作如下: 二.Windows XP中文环境1.  建立或修改C:\Doc ...

  6. web框架django初探

    Web框架介绍 一般会分为两部分:服务器程序和应用程序.服务器程序负责对socket服务器进行封装,并在请求到来时,对请求的各种数据进行整理.应用程序则负责具体的逻辑处理.为了方便应用程序的开发,就出 ...

  7. 【JavaWeb】Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(四)

    SpringSecurity(1) 其实啊,这部分我是最不想写的,因为最麻烦的也是这部分,真的是非常非常的麻烦.关于SpringSecurity的配置,让我折腾了好半天,网上的配置方式一大把,但总有一 ...

  8. 漫步ASP.NET MVC的处理管线

    ASP.NET MVC从诞生到现在已经好几个年头了,这个框架提供一种全新的开发模式,更符合web开发本质.你可以很好的使用以及个性化和扩展这个框架,但这需要你对它有足够的了解.这篇文章主要从整体角度总 ...

  9. Zabbix自定义监控8080端口的连接数

    Zabbix自定义监控8080端口的连接数 一 zabbix自定义监控实现思路 实际上我们要想使用zabbix来监控一些服务的原理很简单,步骤分别是:1.写一个脚本用于获取待监控服务的一些状态信息2. ...

  10. 5种 JavaScript 调用函数的方法

    一次又一次的,我发现,那些有bug的Javascript代码是由于没有真正理解Javascript函数是如何工作而导致的(顺便说一下,许多那样的代码是我写的).JavaScript拥有函数式编程的特性 ...