IE 的 Selenium 脚本

发布于 2024-12-07 15:09:37 字数 378 浏览 2 评论 0原文

我在运行 Internet Explorer 9 的 selenium 脚本时遇到此错误。

 Exception in thread "main" org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information); duration or timeout: 193 milliseconds

I got this error , while running selenium script for Internet Explorer 9.

 Exception in thread "main" org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information); duration or timeout: 193 milliseconds

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

破晓 2024-12-14 15:09:37

有一个错误报告讨论了此问题:http://code.google。 com/p/selenium/issues/detail?id=1795

如果您在所有 Internet Explorer 区域中打开保护模式(IE 设置中的“安全”选项卡),我相信问题已得到解决。

There is a bug report discussing this issue: http://code.google.com/p/selenium/issues/detail?id=1795

If you turn ON protected mode in ALL Internet Explorer Zones (Security Tab in IE settings) I believe the issue is resolved.

半城柳色半声笛 2024-12-14 15:09:37
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(
    InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
    true
); 
WebDriver dr = new InternetExplorerDriver(ieCapabilities);
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(
    InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
    true
); 
WebDriver dr = new InternetExplorerDriver(ieCapabilities);
z祗昰~ 2024-12-14 15:09:37
WebDriver driver = null;
@BeforeSuite
public void suiteSetup() {
    System.setProperty("webdriver.chrome.driver", "D:\\drivers\\chromedriver.exe");
    driver = new ChromeDriver();
}

//Simply create some blank annotations over here for validation purpose
@BeforeTest
public void testSetup() {
    
}

@BeforeMethod
public void methodSetup() {
    
}

@Test

public void testMethod1() throws IOException {
  FileInputStream  file = new FileInputStream("C:\\Users\\Desktop\\Leave_Details.xlsx");
    XSSFWorkbook wb = new XSSFWorkbook(file);// .xslx file

HSSFWorkbook wb = new HSSFWorkbook(file);- .xsl 文件

    XSSFSheet sh = wb.getSheet("Sheet1");

HSSFSheet sh = wb.getSheet("Sheet1");// Sheet1 需要替换为实际的选项卡名称
System.out.println(sh.getRow(0).getCell(0).getStringCellValue()); // 给出数据。需要相应更新行号和列号

    driver.get("url");
    //Get the title of the application
    String strTitle = driver.getTitle();
    System.out.println("Title of the page:"+strTitle);
    
    //No of elements 
    List<WebElement> listElements = driver.findElements(By.xpath("")); // Use findelemet'S' not findelement
    System.out.println(listElements.size());
    
}
@Parameters ({"Type","Name"}) // Add name of parameters added in testng.xml and give name over here and do the same naming in method
@Test
public void testMethod2(String strType, String strName) {
    System.out.println(strType); //Gives the parameter value specified in testng.xml
}

@AfterTest
public void testTearDown() {
    
}

@AfterMethod
public void methodTearDown() {
    
}

@AfterSuite
public void suiteTearDown() {
    driver.close();
}
WebDriver driver = null;
@BeforeSuite
public void suiteSetup() {
    System.setProperty("webdriver.chrome.driver", "D:\\drivers\\chromedriver.exe");
    driver = new ChromeDriver();
}

//Simply create some blank annotations over here for validation purpose
@BeforeTest
public void testSetup() {
    
}

@BeforeMethod
public void methodSetup() {
    
}

@Test

public void testMethod1() throws IOException {
  FileInputStream  file = new FileInputStream("C:\\Users\\Desktop\\Leave_Details.xlsx");
    XSSFWorkbook wb = new XSSFWorkbook(file);// .xslx file

HSSFWorkbook wb = new HSSFWorkbook(file);- .xsl file

    XSSFSheet sh = wb.getSheet("Sheet1");

HSSFSheet sh = wb.getSheet("Sheet1");// Sheet1 need to be replaced with actual tab name
System.out.println(sh.getRow(0).getCell(0).getStringCellValue()); // Gives the data. need to update the row and column numbers accordingly

    driver.get("url");
    //Get the title of the application
    String strTitle = driver.getTitle();
    System.out.println("Title of the page:"+strTitle);
    
    //No of elements 
    List<WebElement> listElements = driver.findElements(By.xpath("")); // Use findelemet'S' not findelement
    System.out.println(listElements.size());
    
}
@Parameters ({"Type","Name"}) // Add name of parameters added in testng.xml and give name over here and do the same naming in method
@Test
public void testMethod2(String strType, String strName) {
    System.out.println(strType); //Gives the parameter value specified in testng.xml
}

@AfterTest
public void testTearDown() {
    
}

@AfterMethod
public void methodTearDown() {
    
}

@AfterSuite
public void suiteTearDown() {
    driver.close();
}
铁憨憨 2024-12-14 15:09:37
File src=new File("filepath/excelsheetname.xlsx");

// load file
FileInputStream fis=new FileInputStream(src);

// Load workbook
XSSFWorkbook wb=new XSSFWorkbook(fis);

// Load sheet- Here we are loading first sheetonly
XSSFSheet sh1= wb.getSheetAt(0);

// getRow() specify which row we want to read.
// and getCell() specify which column to read.
// getStringCellValue() specify that we are reading String data.

System.out.println(sh1.getRow(0).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(0).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(1).getStringCellValue());
File src=new File("filepath/excelsheetname.xlsx");

// load file
FileInputStream fis=new FileInputStream(src);

// Load workbook
XSSFWorkbook wb=new XSSFWorkbook(fis);

// Load sheet- Here we are loading first sheetonly
XSSFSheet sh1= wb.getSheetAt(0);

// getRow() specify which row we want to read.
// and getCell() specify which column to read.
// getStringCellValue() specify that we are reading String data.

System.out.println(sh1.getRow(0).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(0).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(1).getStringCellValue());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文