微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/csharp/99668.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐