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

时间:2013-02-06 13:07:13

标签: c# vb.net visual-studio-2010 coded-ui-tests 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}");


        }        
    }
}

我可以调用MyIntegertestDll方法但是当我调用DeletePhoto方法时会抛出错误:"Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."

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

1 个答案:

答案 0 :(得分:0)

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

VS 2010 Test Agents

VS 2010 SP1