zoukankan      html  css  js  c++  java
  • selenium-打开IE浏览器遇到问题记录

    【使用selenium打开IE浏览器步骤】:

      1、在IE浏览器上运行测试脚本,首先需要下载IEDriverServer.exe,放在IE浏览器的安装目录且同级目录下.

      2、参考代码如下:

    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    import org.openqa.selenium.support.ui.ExpectedCondition;
    import org.openqa.selenium.support.ui.WebDriverWait;import com.thoughtworks.selenium.webdriven.commands.WaitForCondition;
    
    public class SeleniumTest{
        private WebDriver driver;
        @Before
        public void setUp(){
            System.setProperty("webdriver.ie.driver", "C:\Program Files (x86)\Internet Explorer\IEDriverServer.exe");
            driver = new InternetExplorerDriver();
            System.out.println("打开浏览器");
        }
        
        @Test
        public void testLogic(){
            System.out.println("打开——>百度一下");
            driver.get("http://www.baidu.com/");
            WebDriverWait wait = new WebDriverWait(driver, 10);
            WebElement kw = wait.until(new ExpectedCondition<WebElement>() {
                public WebElement apply(WebDriver driver) {
                    return driver.findElement(By.id("kw"));
                }
            });
            try {
                if(kw!=null){
                    kw.sendKeys("selenium");
                    driver.findElement(By.id("su")).click();
                    Thread.sleep(1000);
                }
                System.out.println(driver.getCurrentUrl());
                
                Thread.sleep(10000000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        
        @After
        public void tearDown(){
            if(driver!=null){
                driver.quit();
            }
        }
    }

    【遇到的问题及其解决方案】:

    1、报错:
    java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html 
    解决方法:
       设置 system propertySystem.setProperty("webdriver.ie.driver", "C:\Program Files (x86)\Internet Explorer\IEDriverServer.exe");
     
    2、报错:
    org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 1.15 seconds
    Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
    System info: host: 'PC-201wegfer', ip: '10.1.9.173', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_43'
    Driver info: org.openqa.selenium.ie.InternetExplorerDriver
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     

    解决办法:

    IE安全保护都去掉: 
    internet选项——安全
    internet-启用保护模式 勾去掉 
    本地internet-启用保护模式 勾去掉 
    可信站点-启用保护模式 勾去掉

    除了上面的那几个,还需要在“受限制站点” 去除启用保护模式

  • 相关阅读:
    项目管理【44】 | 项目干系人管理-识别干系人
    移动端开发基础【15】H5和小程序开发注意事项
    召回率recall,IoU, mPA理解,针对video detection领域
    转:batch normalization, instance normalization, layer normalization, group normalization
    自监督(对比学习)资料
    转:非极大值抑制(Non-Maximum Suppression,NMS)
    转:Zero-shot Learning / One-shot Learning / Few-shot Learning
    转:top1错误率、top5正确率
    转:如何理解Inductive bias?
    台式机更新后没有声音了怎么办,Realtek音频管理器
  • 原文地址:https://www.cnblogs.com/splvxh/p/4218682.html
Copyright © 2011-2022 走看看