Highlighted
Absent Member.. Absent Member..
Absent Member..
7217 views

Closing a tab in chrome browser using UFT 12

 

How can I close any particular tab in chrome browser using UFT?

 

OR

 

How can I close all other tabs except for one tab in chrome browser using UFT?

 

  

Any thing will do......

 

 

.

Tags (3)
0 Likes
5 Replies
Highlighted
Contributor.. Contributor..
Contributor..

Have you tried searching this forum? I searched for "Chrome Tab" and got one possible solution instantly.

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

I had seen that solution.. but that involves send keys. I want to avoid using send keys. I am looking for a solution which can give me access to every tab using tab properties.
0 Likes
Highlighted
Contributor.. Contributor..
Contributor..

Try
Browser("index:=1").Close
to close the second tab
0 Likes
Highlighted
Absent Member.
Absent Member.

'This codes will help you to do more. Good luck

Set allBrowser = Desktop.ChildObjects(oDesc)

Set oDesc=Description.Create
    oDesc("micclass").Value="Browser"

'Loop through the collection and close each browser
            If Desktop.ChildObjects(oDesc).Count > 0 Then
                For x = Desktop.ChildObjects(oDesc).Count - 1 To 0 Step -1
                    ihwnd = allBrowser (x).getRoProperty("hwnd")
                    If ihwnd>0  Then
                    'Windows IE browser
                        Window("hwnd:=" & ihwnd).Activate
                        Window("hwnd:=" & ihwnd).close
                    else
                    'Others Web Browsers
                        sName =allBrowser (x).getRoProperty("title") 'If you want to know the title
                        On error resume next
                        allBrowser (x).close  
                    End If
                Next
            End If 

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Does this mean that usage of hwnd when working with Chrome browser is out of the question? The reason I ask is because the framework I am working on to check for Chrome compatibility heavily uses the hwnd property to execute automated tests. Till now IE has been the only browser used for these tests but I am trying to find a way to make them Chrome compatible. Is this possible? I've noticed that hwnd is always returned as 0 by UFT 12 for Chrome and therefore, the scripts fail. Moreover, I even tried the using FindWindow to get the hwnd for Chrome and I get some value in return but it still fails and I'm assuming this is because the value returned is wrong. 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.