当 QTP 也做同样的事情时,我可以直接使用 vbscript 编写操作吗?
基本疑问...如果QTP在我们记录动作时生成vbscript代码,我们不能直接编写vbscript代码并摆脱也做同样事情的QTP吗?
Basic doubt...If QTP generates vbscript code as we record actions, can't we directly write vbscript code and get rid of QTP which does the same thing too?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的。 您可以自己编写代码,但必须将其粘贴到 QTP UI 中。
不。QTP 是贯穿它的引擎。 VBScript 依赖 QTP UI 来执行相关操作,例如单击网页上的链接。
Yes. You can write the code yourself, but you'd have to paste it into the QTP UI.
No. QTP is the engine that runs through it. The VBScript relies on the QTP UI to perform the actions in question, such as clicking on a link on a web page.
我认为您想问的问题是:我可以仅使用 VBScript 编写自动化测试脚本而不使用 QTP 本身吗?
QTP 本身提供了用于自动化测试的特定设施/功能。 VBScript 只是一种脚本语言,可让您按照您选择的顺序将这些功能结合在一起。
例如,QTP提供了对象识别系统...它使您能够通过简单地调用以下方法来单击特定窗口中的特定按钮:Window("MyApp").Button("OK").Click
如果没有 QTP,该设施就不存在。
QTP 提供的其他有用功能包括 DataTables、Timers、Reporter 和整个 Actions 系统。 如果没有 QTP,VBScript 就无法使用这些功能。
所以,我对你问题的回答是 - 是的,你可以,但是你必须找到另一种方法来完成所有这些事情。
I think the question you're trying to ask is: Can I write automated test scripts using just VBScript without using QTP itself at all?
QTP itself provides specific facilities/features for automating tests. VBScript is simply the script language chosen to let you tie those features together in the order you choose.
For example, QTP provides the object recognition system... which gives you the ability to click on a specific button in a specific window by simply calling the method: Window("MyApp").Button("OK").Click
Without QTP, that facility doesn't exist.
Other useful features provided by QTP are DataTables, Timers, Reporter, and the whole Actions system. Without QTP, VBScript just doesn't have those available.
So, my answer to your questions is - Yeah, you could, but then you'd have to find another way to do all that stuff.
虽然您可以在任何文本编辑器(无论是 QTP IDE、记事本还是您选择的任何其他编辑器)中编写 QTP 测试脚本,但您只能在 QTP 扩展时运行它们VBScript 拥有自己的对象模型,提供测试对象(例如
Browser
)和测试操作(例如Click
)。 在 QTP 之外,这些对象和操作未定义,因此您无法直接通过 Windows Script Host 运行测试脚本。While you can write QTP test scripts in any text editor (whether QTP IDE, Notepad or any other editor of your choice), you can run them only from QTP as it extends VBScript with its own object model providing the test objects (e.g.
Browser
) and test actions (e.g.Click
). Outside of QTP these objects and actions are not defined, so you can't run test scripts directly via Windows Script Host.