CodedUI测试更改URL

时间:2013-11-26 14:52:03

标签: c# testing url-rewriting automated-tests coded-ui-tests

我想在我的系统中以不同的副本(不同的url-同一系统)运行我记录的编码ui测试。我需要更改URL字符串,我想在我的测试文件中执行此操作(在本例中命名为:d01.cs) 这里是: 我有一个测试名称D01.cs,这是我定义参数的部分:

 public void D01()
        {

            this.UIMap.D01Params.UIRtbTxt1EditText = TestContext.DataRow["test1"].ToString();
            this.UIMap.D01();

In UIMap.Designer i found this:


public class D01Params
 #region Fields
        /// <summary>
        /// Go to web page 'http://localhost:8095/Login.aspx' using new browser instance
        /// </summary>
        public string UIBlankPageWindowsInteWindowUrl = "http://localhost:8095/Login.aspx"

我想在我的D01.cs文件中将url写为参数。我想从excel中取出它,如果可能的话......但我找不到正确的属性来设置它。 this.UIMAP ...没有回答

我该怎么办?我试着用: this.UIBlankPageWindowsInteWindowUrl 但仍然没有工作。

3 个答案:

答案 0 :(得分:2)

根据我在CUIT中的经验,CUI Test Builder为我们生成的方法创建了一个params类。 如果你去定义你的方法(F12),你会找到这一行。

BrowserWindow browser = BrowserWindow.Launch(new System.Uri(this.D01Params.Url));

您可以使用

将自己的网址分配给D01Params
this.UIMap.D01Params.UIBlankPageWindowsInteWindowUrl = this.TestContext.DataRow["YourNewUrl"].ToString();
this.UIMap.D01Params.UIRtbTxt1EditText = TestContext.DataRow["test1"].ToString();
this.UIMap.D01();

答案 1 :(得分:1)

你说你想从excel导入但我没有在你的代码中看到数据源。你为excel设置了DataSource吗?

例如:

DataSource("System.Data.Odbc", "Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};dbq=|DataDirectory|\\Data.xls;defaultdir=.;driverid=790;maxbuffersize=2048;pagetimeout=5;readonly=true", "Sheet1$", DataAccessMethod.Sequential), TestMethod]

设置数据源后,您现在可以从数据源访问数据行。

访问列的语法如下:

string paramVal = TestContext.DataRow["Input1"]

答案 2 :(得分:0)

如果您在the directions的第二个回答中关注link I sent you,则可以找到有关如何从Excel工作表中获取数据的说明。

然后你可以将这些数据放入:

BrowserWindow window = BrowserWindow.Launch(new System.Uri(urlFromExcel));