c# – 如何将VSTS编码的Ui脚本调用到QTP?

前端之家收集整理的这篇文章主要介绍了c# – 如何将VSTS编码的Ui脚本调用到QTP?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在QTP上执行我的Coded UI脚本.
首先我为我的Coded UI项目创建了一个dll后来我能够从该dll访问方法,但我无法访问Coded UI测试方法.
例:
以下脚本在VSTS中的C#中
namespace TestProject1
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Input;
    using System.Windows.Forms;
    using System.CodeDom.Compiler;
    using System.Text.RegularExpressions;
    using Microsoft.VisualStudio.TestTools.UITest.Extension;
    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
    using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;    
    using MouseButtons = System.Windows.Forms.MouseButtons;
    using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
    using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
    using Microsoft.VisualStudio.TestTools.UITesting.WpfControls;

    public partial class UIMap
    {
        public int MyInteger()
        {
            return 9;
        }
        public string testDll()
        {
            return "Test DLL Factory";
        }
        public void add1()
        {
            MessageBox.Show("Sravan");

        }
        public void DeletePhoto()
        {
            WinWindow window = new WinWindow();
            window.SearchProperties[WinWindow.PropertyNames.Name] = "Cyramed";
            window.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName,"WindowsForms10.Window",PropertyExpressionOperator.Contains));

            WinWindow c_window = new WinWindow(window);
            c_window.SearchProperties[WinWindow.PropertyNames.ControlName] = "PICTUREBox1";
            c_window.WindowTitles.Add("Cyramed");
            c_window.DrawHighlight();

            WinClient c_client = new WinClient(c_window);
            c_client.WindowTitles.Add("Cyramed");
            c_client.DrawHighlight();

            Mouse.Click(c_client,MouseButtons.Right);
            Keyboard.SendKeys("{DOWN}");
            Keyboard.SendKeys("{DOWN}");
            Keyboard.SendKeys("{DOWN}");
            Keyboard.SendKeys("{ENTER}");


        }        
    }
}

我可以调用MyInteger和testDll方法,但是当我调用DeletePhoto方法时,它会抛出一个错误:“无法加载文件或程序集’Microsoft.VisualStudio.TestTools.UITesting,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a’或它的一个依赖项.系统找不到指定的文件.“

我主要担心的是:我也希望在QTP上执行Coded UI脚本.

解决方法

您可能必须在QTP测试代理上安装Visual Studio测试代理.这些将丢弃机器上的二进制文件.

VS 2010 Test Agents

VS 2010 SP1

原文链接:https://www.f2er.com/csharp/99668.html

猜你在找的C#相关文章