简体   繁体   中英

How to open chrome new session using UFT

Sometimes chrome is already open. During run time, UFT opens the AUT in chrome. The script fails sometimes because chrome was already open before the test run. I usually keep the chrome closed before the test runs for a consistent test run. However, it is difficult to keep chrome closed always because I need to keep other applications like Gmail open while I am running tests.

This is the code I have to open chrome.

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

How can UFT open the new session of chrome so UFT ignores the previous session of chrome during run time?

@bugfinder

Option1: Killing the chrome process when you run the test

SystemUtil.CloseProcessByName("chrome.exe")

Option2: Use "CreationTime:=1" ordinal identifier to perform actions on newly created browser instance If the UFT will run only on the second browser If you want to open 2 browsers and wanted to perform actions on a third browser then use "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"

Use the SytemUtil.CloseProcessbyWndTitle

You can provide regular expressions if parts of the title of your application are changing.

In case that is not possible, I'm afraid you will have to write your own cleanup method where you close all Chrome Instances except the ones you want to spare.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM