您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源功能測(cè)試工具 > Selenium
讓自己的Selenium程序成功的自動(dòng)打開(kāi)網(wǎng)頁(yè)-問(wèn)題記錄
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/6/27 14:06:53 ] 推薦標(biāo)簽:單元測(cè)試 Selenium

  第一次執(zhí)行:
package mycss;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Test1 {
public static void main(String[] args) {
WebDriver driver = new InternetExplorerDriver();
driver.get("www.baidu.com");
}
}
  報(bào)錯(cuò)如圖:

  下載IEDriverServer.exe并放在代碼工程路徑下面,然后修改代碼繼續(xù)運(yùn)行:
package mycss;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Test1 {
public static void main(String[] args) {
String IEPath = "C:\Program Files\Internet Explorer\iexplore.exe";
String pro_Path = System.getProperty("user.dir");
String IEDriver_Path = pro_Path + "\IEDriverServer.exe";
System.setProperty("webdriver.ie.bin", IEPath);
System.setProperty("webdriver.ie.driver", IEDriver_Path);
WebDriver driver = new InternetExplorerDriver();
driver.get("www.baidu.com");
}
}
  運(yùn)行后又報(bào)錯(cuò):

  再次修改:
package mycss;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Test1 {
public static void main(String[] args) {
//ie瀏覽器路徑
String IEPath = "C:\Program Files\Internet Explorer\iexplore.exe";
String pro_Path = System.getProperty("user.dir");
//打開(kāi)ie瀏覽器的driver
String IEDriver_Path = pro_Path + "\IEDriverServer.exe";
System.setProperty("webdriver.ie.bin", IEPath);
System.setProperty("webdriver.ie.driver", IEDriver_Path);
//設(shè)置IE安全機(jī)制
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
WebDriver driver = new InternetExplorerDriver(ieCapabilities);
driver.get("www.baidu.com");
}
}
  這次終于打開(kāi)IE瀏覽器了。

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd