码迷,mamicode.com
首页 > 其他好文 > 详细

selenlium 实践 2

时间:2016-02-23 11:12:59      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

FirefoxProfile定制启动firefox

 

 1 package seleniumtraining1;
 2 
 3 import java.io.File;
 4 import java.io.IOException;
 5 
 6 import org.openqa.selenium.By;
 7 import org.openqa.selenium.WebDriver;
 8 import org.openqa.selenium.WebElement;
 9 import org.openqa.selenium.firefox.FirefoxDriver;
10 import org.openqa.selenium.firefox.FirefoxProfile;
11 import org.openqa.selenium.support.ui.ExpectedConditions;
12 import org.openqa.selenium.support.ui.WebDriverWait;
13 
14 public class seleniumtest1 {
15 
16     public static void main(String[] args) {
17         String profileInJson = "";
18         FirefoxProfile profile = new FirefoxProfile();
19         try{
20             profile.addExtension(new File("/path/to/extension.xpi"));
21             profile.setPreference("browser.startup.homepage", "about.blank");
22             profile.setAssumeUntrustedCertificateIssuer(false);
23             profile.setAcceptUntrustedCertificates(false);
24             
25             profileInJson = profile.toJson();
26             System.out.println(profileInJson);
27         }catch(IOException e){
28             e.printStackTrace();
29         }
30         System.setProperty("webdriver.firefox.bin","D:/Program Files/Mozilla firefox4002/firefox.exe"); 
31         WebDriver driver = new FirefoxDriver();
32         driver.get("http://www.daidu.com");
33         String url = driver.getCurrentUrl();
34         System.out.println(url);
35         driver.close();
36     } 
37 
38 }

 

selenlium 实践 2

标签:

原文地址:http://www.cnblogs.com/xlmig/p/5209044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!