运行硒的webdriver测试用例对多个浏览器 [英] running selenium webdriver test cases against multiple browsers

查看:282
本文介绍了运行硒的webdriver测试用例对多个浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的硒测试。我想运行硒测试用例对上的Internet Explorer,Firefox,Opera和Chrome的多个浏览器。我有什么办法可循。你能请的人建议我这是最好的方法。

请问硒的网络驱动器支持多种浏览器或不???

我们写登录脚本。它运行成功的为火狐,Chrome和Internet Explorer分别。但我想顺序运行这些多个浏览器。


解决方案

 进口org.junit.Test;
进口org.openqa.selenium.WebDriver;
进口org.openqa.selenium.chrome.ChromeDriver;
进口org.openqa.selenium.firefox.FirefoxDriver;
进口org.openqa.selenium.ie.InternetExplorerDriver;公共类样品{
    私人的webdriver _driver;    @测试
    公共无效IEconfiguration()抛出异常{
        System.setProperty(webdriver.ie.driver
        D:/软件/硒软件/驱动器/ IEDriverServer.exe);
        _driver =新InternetExplorerDriver();
        登录();
    }    @测试
    公共无效FFconfiguration()抛出异常{
        _driver =新FirefoxDriver();
        登录();
    }    @测试
    公共无效CRconfiguration()抛出异常{
        System.setProperty(webdriver.chrome.driver
                D:/软件/硒软件/驱动器/ chromedriver.exe);
        _driver =新ChromeDriver();
        //_driver.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);
        登录();
    }    公共无效登录()抛出异常{
        _driver.get(http://www.google.com);
    }
}

这之前,我们必须安装Chrome和Internet Explorer驱动程序的.exe文件,并运行这些。

I am new to selenium testing. I want to run selenium test cases on multiple browsers against internet explorer, Firefox, opera and chrome. What approach i have to follow. Can you people please suggest me which is the best process.

Does selenium web driver supports multiple browsers or not???

We had written login script. It runs successful for Firefox, chrome and internet explorer individually. But i want to run it for those multiple browsers sequentially.

解决方案

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class Sample {
    private WebDriver _driver;

    @Test
    public void IEconfiguration() throws Exception {
        System.setProperty("webdriver.ie.driver",
        "D:/Softwares/Selenium softwares/drivers/IEDriverServer.exe");
        _driver = new InternetExplorerDriver();
        login();
    }

    @Test
    public void FFconfiguration() throws Exception {
        _driver = new FirefoxDriver();
        login();
    }

    @Test
    public void CRconfiguration() throws Exception {
        System.setProperty("webdriver.chrome.driver",
                "D:/Softwares/Selenium softwares/drivers/chromedriver.exe");
        _driver = new ChromeDriver();
        //_driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
        login();
    }

    public void login() throws Exception {
        _driver.get("http://www.google.com");
    }       
}

Before that we have to install the chrome and internet explorer drivers .exe files and run those.

这篇关于运行硒的webdriver测试用例对多个浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆