c# - CodedUI 测试更改 URL

标签 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 但仍然无法正常工作。

最佳答案

正如我在 CUIT 方面获得的经验一样,CUI 测试生成器为我们生成的方法创建了一个 params 类。 如果您转到方法的定义(F12),您会找到这一行。

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

您可以将自己的 URL 分配给 D01Params

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

关于c# - CodedUI 测试更改 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20220370/

相关文章:

ruby-on-rails - Rspec 条件断言 : have_content A OR have_content B

c# - 可以使用 Visual Studio 和 Xamarin Studio 构建 Xamarin 项目吗?

c# - 即使未调用 System.Transactions.TransactionScope.Commit() 也已提交数据

java - 如何测试包装另一个方法的方法?

python - 测试工具 ConcurrentStreamTestSuite 的一个简单的工作示例

php - 让一些 RewriteCond 影响多个规则

wordpress - 漂亮的 url 与 .htaccess?

php - 如何用破折号替换codeigniter url中的下划线?

c# - 巨大的内存数据集。需要通过整数 Id 属性进行快速搜索

c# - ASP.NET 身份发送电子邮件 : TaskCanceledException