zoukankan      html  css  js  c++  java
  • Selenium对浏览器的支持

    1.火狐浏览器

    优点:FireFox Dirver对页面的自动化测试支持得比较好,很直观地模拟页面的操作,对JavaScript的支持也非常完善,基本上页面上做的所有操作FireFox Driver都可以模拟。

    缺点:启动很慢,运行也比较慢,不过,启动之后Webdriver的操作速度虽然不快但还是可以接受的,建议不要频繁启停FireFox Driver。

    使用:

    WebDriver driver = new FirefoxDriver();

    Firefox profile的属性值是可以改变的,比如我们平时使用得非常频繁的改变useragent的功能,可以这样修改:

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("general.useragent.override", "some UAstring");
    WebDriver driver = new FirefoxDriver(profile);

    2.谷歌浏览器

    注:个人只能打开谷歌浏览器,需调用D盘目录下的谷歌驱动

    System.setProperty("webdriver.chrome.driver", "D:\chromedriver.exe");//默认调用的是火狐浏览器,目前调用D盘目录下的谷歌驱动,从而打开谷歌浏览器

    driver = new ChromeDriver();

    3.IE浏览器

    优点:直观地模拟用户的实际操作,对JavaScript提供完善的支持。

    缺点:是所有浏览器中运行速度最慢的,并且只能在Windows下运行,对CSS以及XPATH的支持也不够好。

    使用:

    WebDriver driver = new InternetExplorerDriver();

  • 相关阅读:
    Compiler OverView
    二叉查找树
    [C++] manage background threads with boost::thread
    模拟类式继承
    JavaScript Curry
    Get GetProcAddress Function Address
    ASP.MVC Session为null
    ASP.NET MVC项目Forms身份验证HttpContext.Current.User为空
    Java Bean Validation学习笔记
    java开发中sql注入正则表达式检测
  • 原文地址:https://www.cnblogs.com/ydnice/p/5787519.html
Copyright © 2011-2022 走看看