zoukankan      html  css  js  c++  java
  • selenium 学习笔记 ---新手学习记录(2) 问题总结

    今天研究了下ie、chrome、firefox浏览器执行脚本

    1.首先firefox下执行时,我是安装在d盘了,所以要更改路径

     //如果火狐浏览器没有默认安装在C盘,需要制定其路径
     System.setProperty("webdriver.firefox.bin", "D:/Softwareinstallation/huohu/firefox.exe");
     WebDriver driver = new FirefoxDriver();

    2.在chrome下执行时,遇到了如下问题

    Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list

    解决方法:

    下载chrome驱动插件,(包含ie驱动插件),代码如下,还有问题的话,把路径加到path变量中

    http://yunpan.cn/c3kPMJTZDDLyv  访问密码 4dd5

    1 //谷歌浏览器
    2 System.setProperty("webdriver.chrome.driver", "C:\Users\Administrator\Desktop\testzidong\selenium\anzhuangbao\chromedriver_win32\chromedriver.exe");       
    3 WebDriver driver=new ChromeDriver();
    4         

    3.在ie下运行时出现上面类型问题。解决方法同上

    代码如下:

    1 System.setProperty("webdriver.ie.driver", "C:\Users\Administrator\Desktop\testzidong\selenium\anzhuangbao\IEDriverServer_x64_2.48.0\IEDriverServer.exe"); 
    2  WebDriver driver = new InternetExplorerDriver();

    但是在运行时又包了其他错。

    解决方法如下: 把ie选项中的安全区域全部打上钩

  • 相关阅读:
    异常处理
    注解配置的Spring MVC
    React router
    Redux管理你的React应用
    Spring.Net 初探
    有效的XML: DTD(文档类型定义)介绍(转)
    Python 目录操作(转)
    nginx做反向负载均衡,后端服务器获取真实客户端ip(转)
    以正确的方式开源 Python 项目(转)
    Linux访问Windows共享文件夹 (转)
  • 原文地址:https://www.cnblogs.com/kllay/p/5036932.html
Copyright © 2011-2022 走看看