自动化测试--selenium-webDriver

webDriver介绍

webDriver是为了解决selenium-rc-api一些局限性,而设计提供了的更简单,更容易编码的接口。selenium-webDriver是为更好地支持动态网页,在重新加载的时候页面元素发生变化而开发的。webDriver的目标是提供一个良好设计的面向对象的,能够提供支持现在一些高级的webApp的测试问题。

webDriver和selenium-rc在驱动浏览器方面有什么不同

selenium-webDriver是直接调用各种浏览器内置的方法实现自动化。如何直接调用,取决于你所使用的浏览器。
使用selenium-rc的人,应该了解,这和使用selenium-rc的区别是很大的。selenium-rc的运行机制对不同的浏览器都是一样的。selenium-rc内置了js的方法在你所使用的浏览器内部,当浏览器打开的时候,他会使用js去驱动浏览器内部的aut.再次强调,webDriver没有使用这种机制,他是直接调用浏览器内置机制完成自动化。

webDriver和selenium-Driver

你可能需要也可能不需要selenium-driver取决于你想如何使用selenium-webDriver.如果你仅仅想使用selenium-webDriver那么你不需要selenium-server.如果你的浏览器和测试执行都只是在同一台机器,那么也不需要selenium-server.
        以下几种情况你可能需要selenium-server
        1、要使用selenium-grid把你的测试用例分布到不同的机器或者虚拟机执行。
        2、要使用远程的机器上面特定的浏览器版本。
        3、你想要使用java或者ruby,c#,python 而是想要使用 HtmlUnit Driver 那么需要selenium-server

创建一个selenium-webDriver工程---java版本

    1、创建一个maven普通工程。
     2、添加selenium-server依赖,以及要使用的浏览器对应的driver
      
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>MySel20Proj</groupId>
        <artifactId>MySel20Proj</artifactId>
        <version>1.0</version>
        <dependencies>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>2.33.0</version>
            </dependency>
            <dependency>
                <groupId>com.opera</groupId>
                <artifactId>operadriver</artifactId>
            </dependency>
        </dependencies>
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.opera</groupId>
                    <artifactId>operadriver</artifactId>
                    <version>1.3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.seleniumhq.selenium</groupId>
                            <artifactId>selenium-remote-driver</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </dependencyManagement>
</project>
      3、执行mvn clean install  、和mvn eclipse:eclipse 完成构建、

  注释:工程创建以后,如何编码脚本,下次再写、
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值