与Specflow的DataSource属性为多浏览器测试 [英] DataSource attribute with Specflow for multiple browser testing

查看:222
本文介绍了与Specflow的DataSource属性为多浏览器测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是通过硒browserstack执行在C#中一些web UI测试。目前这些都只是简单的单元测试的MS和他们反对票不同的浏览器执行。
我想端口测试specflow,但我真的不知道该怎么办了多个浏览器测试一下。

目前,执行在多个浏览器这些测试我使用的是数据源的属性,它基本上需要从XML文件用于相同的测试不同的输入

  [TestMethod的]
[忽视]
[DeploymentItem(JLL.Specs \\\\ Browsers.xml)]
[数据源(Microsoft.VisualStudio.TestTools.DataSource.XML,| DataDirectory目录| \\\\ Browsers.xml,行,DataAccessMethod.Sequential)
公共无效LoadHomePageAndFindSearchBox()
{
   ...
}

问题在于Specflow不支持的数据源属性。
任何想法?

这是XML文件:

 <?XML版本=1.0编码=UTF-8&GT?;
<行和GT;
  <行>
    <浏览器与GT; Firefox和LT; /浏览器>
    <&BROWSER_VERSION GT; 31.0< / BROWSER_VERSION>
    < OS> Windows和LT; / OS>
    < OS_VERSION> 7 LT; / OS_VERSION>
    <分辨率和GT; 1280×1024< /分辨率>
    < browserName>< / browserName>
    <平台和GT;< /平台>
    &所述;装置>&下; /装置>
  < /行>
  <行>
    <浏览器与GT;浏览器< /浏览器>
    <&BROWSER_VERSION GT; 36.0< / BROWSER_VERSION>
    < OS> Windows和LT; / OS>
    <&OS_VERSION GT;&XP LT; / OS_VERSION>
    <分辨率和GT; 1024×768< /分辨率>
    < browserName>< / browserName>
    <平台和GT;< /平台>
    &所述;装置>&下; /装置>
  < /行>...


解决方案

最好是使用 Baseclass.Contrib.SpecFlow.Selenium.NUnit DLL

看到示例:

  @Browser:IE@Browser:铬@Browser:火狐

方案概要:两个数字相加

您可以使用 @Browser:.......... 在功能的文件。此属性将列出您的测试资源管理器3测试每个浏览器,你可以运行任何你想要使用。

有关详细信息,请这里

I have some web ui tests in C# which are executed through selenium in browserstack. Currently these are just simple unit ms tests and they are executed againts different browsers. I want to port the test to specflow, but I don't really know how to do the multiple browser testing bit.

At the moment, to execute these tests in multiple browsers I am using a DataSource attribute, which basically takes different inputs for the same tests from an XML file

[TestMethod]
[Ignore]
[DeploymentItem("JLL.Specs\\Browsers.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\Browsers.xml", "Row", DataAccessMethod.Sequential)]
public void LoadHomePageAndFindSearchBox()
{    
   ...
}

The problem is that Specflow doesn't support the DataSource attribute. Any idea?

This is the XML file:

<?xml version="1.0" encoding="utf-8" ?>
<Rows>
  <Row>
    <browser>Firefox</browser>
    <browser_version>31.0</browser_version>
    <os>Windows</os>
    <os_version>7</os_version>
    <resolution>1280x1024</resolution>
    <browserName></browserName>
    <platform></platform>
    <device></device>
  </Row>
  <Row>
    <browser>Chrome</browser>
    <browser_version>36.0</browser_version>
    <os>Windows</os>
    <os_version>XP</os_version>
    <resolution>1024x768</resolution>
    <browserName></browserName>
    <platform></platform>
    <device></device>
  </Row>

...

解决方案

Best is to use Baseclass.Contrib.SpecFlow.Selenium.NUnit dll.

see the Example:

@Browser:IE

@Browser:Chrome

@Browser:Firefox

Scenario Outline: Add Two Numbers

You can use @Browser:.......... in your feature file. This attribute will list 3 tests in your test explorer for each browser and you can run whichever you wanted to use.

For detailed information , go here.

这篇关于与Specflow的DataSource属性为多浏览器测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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