Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to close the new browser - when clicked on attachment
#1
Solved: 11 Years, 3 Months, 2 Weeks ago
Dear All,

Hope you are doing well. I am facing a silly problem.

scenario is like this:
1. On a webpage, I need to add few attachments with extensions like .txt, .doc, .xls, .jpg, .bmp etc
2.After that when I click on those links (example: samplefile.txt or samplefile.bmp) for some of the filetypes, new browser is getting opened (for all image files and text files, new browser gets opened)
3.I need to close this browser --this is the verification procedure to validate that the file has been opened.

I tried with If Browser("CreationTime:=1").exist then Browser("CreationTime:=0").close

On my application, 1st browser is QCenter 2nd will be my application and this 3rd browser gets opened when I click on these image files, new browser gets opened, it has to be closed.

I want to close the recently opened browser.

Please provide me solutions ASAP.
Thanks,
kishore
Reply
#2
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi Kishore,

I would suggest you to go with the below way.

Step1: Create a Description object for "Browser" object class and Retrieve the Active browser count after clicking on the image/text files.
Step2: Use the loop > iterate thru the loop and retrieve the Browser property "Name" value using GetROProperty.
Step3: Use Instr function to search for the expected filename content in the entire Browser Name > once it is found > close the current browser > Exit out of the Loop

Code will be something like this as given below :

Code:
Expected_FileName="test Image file Filename"    
   Set br=description.Create
   br("micclass").value="Browser"

   Set br_collection=Desktop.ChildObjects(br)
   br_count=br_collection.count-1
  
    For i=0 to br_count
         Current_brName=br_collection(i).GetROProperty("Name")
            If (instr(1,Current_brName,Expected_ImageFileName)>0) then
                  br_collection(i).close
           Exit for
            End if  
    Next

It would work fine as you expected Smile
Reply
#3
Solved: 11 Years, 3 Months, 2 Weeks ago
Thanks my dear friend.

Let me try this one and get back to you. BTW, new browser will open for sample.txt, sample.bmp, sample.pdf. sample.gif, sample.jpg files alone.

In that case, how do I give the Expected_FileName value?

In the datatable, I have the paths of the filenames
1.sample.txt
2.sample.bmp
3.sample.jpg
4.sample.gif
5.sample.pdf
6.sample.html
7.sample.xls
8.sample.doc

I am making use of For i=1 to Datatable.Getsheet("sheetname").Getrowcount

Inside the loop, I am attaching files and opening those attachments.
I need to throw a reporter.pass message or fail message once these files are viewable, then this is pass else fail

Please advise!
thanks
kish

Moreover, when I click on these attachments, (bmp,gif,pdf,html,jpg), new browser gets opened, but its name/title is just "browser" thats all. I tried to record and added to OR as well, same thing is happening, no specific name or title is being identified for this browser.

Please advise!
kishore
Reply
#4
Solved: 11 Years, 3 Months, 2 Weeks ago
Dear all,

I got the solution by for my problem

Code:
Function CloseRecentlyOpenedBrowser()

Dim oDescription
Dim BrObjectList
Dim oLatestBrIndex

Set oDescription=Description.Create
oDescription("micclass").value="Browser"
Set BrowserObjectList=Desktop.ChildObjects(oDescription)
oLatestBrIndex=BrObjectList.count-1

Browser("creationtime:="&oLatestBrIndex).close

Set oDescription=Nothing
Set BrObjectList=Nothing
End Function
I found this function in one of the sites and I made changes to it as per my requirement.

Thanks guys!
Kishore
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to Close UFT 14.53 through AOM Object y.srihari 1 2,366 12-26-2019, 08:43 PM
Last Post: y.srihari
  Using UFT 14.0 on Win 10, unable to find 'Register New Browser Control' utility soujanya 2 3,195 04-23-2018, 07:24 PM
Last Post: soujanya
  UFT 12.0 is unable to identify the java Applet on Safari browser(MAC OS) Mahesh Kolla 0 2,745 05-29-2014, 12:49 PM
Last Post: Mahesh Kolla
  Close Tab Recognizes GetROProperty. WHY??? Ayesha 5 4,065 07-24-2013, 10:39 AM
Last Post: vinod123
  How to find the latest modified file in QC11 current test attachment using QTP10 shiv.cse 0 1,874 07-23-2013, 01:25 AM
Last Post: shiv.cse

Forum Jump:


Users browsing this thread: 1 Guest(s)