如何将VSTS编码的Ui脚本调用到QTP
本文关键字:脚本 调用 QTP Ui VSTS 编码 | 更新日期: 2023-09-27 17:57:51
我正试图在QTP上执行我的编码UI脚本。首先,我为我的编码UI项目创建了一个dll,后来我可以访问该dll中的方法,但我无法访问编码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
方法时,它会抛出一个错误:"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上执行编码的UI脚本。
您可能需要在QTP测试代理上安装Visual Studio测试代理。这将把二进制文件放到机器上。
VS 2010测试代理
VS 2010 SP1