【问题标题】:How to open chrome new session using UFT如何使用 UFT 打开 chrome 新会话
【发布时间】:2021-05-15 21:32:56
【问题描述】:

有时 chrome 已经打开。在运行时,UFT 在 chrome 中打开 AUT。脚本有时会失败,因为在测试运行之前 chrome 已经打开。我通常在测试运行之前保持 chrome 关闭,以便进行一致的测试运行。但是,始终保持 chrome 关闭是很困难的,因为我需要在运行测试时保持其他应用程序(如 Gmail)处于打开状态。

这是我必须打开 chrome 的代码。

SystemUtil.Run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","www.google.com"

UFT 如何打开新的 chrome 会话,以便 UFT 在运行时忽略上一个 chrome 会话?

【问题讨论】:

  • UFT 在脚本开始时使用WMI 查询杀死任何现有的chrome.exe 进程,然后您的命令将始终打开一个新会话

标签: hp-uft


【解决方案1】:

@bugfinder

选项1:在运行测试时终止 chrome 进程

SystemUtil.CloseProcessByName("chrome.exe")

选项2:使用“CreationTime:=1”序号标识符对新创建的浏览器实例执行操作 如果 UFT 将仅在第二个浏览器上运行 如果您想打开 2 个浏览器并想在第三个浏览器上执行操作,请使用 "CreationTime:=2"

SystemUtil.Run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","www.google.com"
Browser("CreationTime:=1").Page("title:=Google").WebEdit("name:=q").Set "what to search"

【讨论】:

    【解决方案2】:

    使用SytemUtil.CloseProcessbyWndTitle

    如果应用程序的部分标题发生变化,您可以提供正则表达式。

    如果这是不可能的,恐怕你将不得不编写自己的清理方法,关闭所有 Chrome 实例,除了你想要备用的实例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-13
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-17
      相关资源
      最近更新 更多