首页 > 其他 > 详细

selenlium 实践 2

时间:2016-02-23 11:12:36      阅读:230      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!