Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
HGrube Absent Member.
Absent Member.
4215 views

Retrieve URL from web browser (Internet Explorer) with SilkTest Workbench

Jump to solution

I would like to retrieve the actual URL from the address line in my browser (Internet Explorer). Unfortunately I have not been very successfully by using TextCapture of the WebBrowser.TextField or using the 'Text' property of the WebBrowser.TextField in a Visual Test.

Example code for .Net test scripts are welcome too...

Thanks

Holger

 

0 Likes
1 Solution

Accepted Solutions
Thomas Krupa Absent Member.
Absent Member.

RE: Retrieve URL from web browser (Internet Explorer) with SilkTest Workbench

Jump to solution

Holger,

for .NET scripts you could use the following script:

Public Sub Main()
	With _desktop.BrowserApplication("WebBrowser")			
	    Dim url As String = _desktop.BrowserWindow.GetUrl()
	    MsgBox(url)
	End With		
End Sub


To do same in VT use these steps:

1.) Open the identify object dialog
2.) Click on "Start Identify"
3.) Select any browser object - e.g. the address bar
4.) The Identfy Object dialog adds elements that it recognized. Quite on the top you find a locator called "BrowserWindow". It has an attribute "url". Select that attribute.
5.) Click on Paste
6.) In the popup dialog select "GetUrl" and click OK

Thomas

0 Likes
4 Replies
saraswatti Absent Member.
Absent Member.

RE: Retrieve URL from web browser (Internet Explorer) with SilkTest Workbench

Jump to solution

In one of my tests I get the address of my browser as follows: (.Net script)

       Dim url As String

With _desktop.BrowserApplication(sBrowser)

url = .TextField("urlField").Text

End With

0 Likes
AndySchott Absent Member.
Absent Member.

RE: Retrieve URL from web browser (Internet Explorer) with SilkTest Workbench

Jump to solution

You can use the following script to get the current URL:

Imports SilkTest.Ntf.XBrowser

Public Module Main
    Dim _desktop As Desktop = Agent.Desktop

    Public Sub Main()
        With _desktop.BrowserApplication()
            Dim url As String = .TextField().Text
            MsgBox(url)
        End With
    End Sub
End Module

To do this from a visual test, select Insert > Property from Control, identify the TextField in the address bar, and choose the Text property.

Andy

0 Likes
HGrube Absent Member.
Absent Member.

RE: Retrieve URL from web browser (Internet Explorer) with SilkTest Workbench

Jump to solution

Thank you very much for your answers. Both methods .Net code and Visual Test hint work well for (e.g. Internet Explorer) and a "standard" url.

But if I try to catch the URL from a PDF document which is directly displayed in the browser (via the Acrobat Reader Addon) I get only the value "73%" back. The URL I am using looks like "S:\folder\productname 7.3\component\Manuals\manualtitle7.3.1_de.pdf" ...

Do you have another idea?

Kind regards

Holger

0 Likes
Thomas Krupa Absent Member.
Absent Member.

RE: Retrieve URL from web browser (Internet Explorer) with SilkTest Workbench

Jump to solution

Holger,

for .NET scripts you could use the following script:

Public Sub Main()
	With _desktop.BrowserApplication("WebBrowser")			
	    Dim url As String = _desktop.BrowserWindow.GetUrl()
	    MsgBox(url)
	End With		
End Sub


To do same in VT use these steps:

1.) Open the identify object dialog
2.) Click on "Start Identify"
3.) Select any browser object - e.g. the address bar
4.) The Identfy Object dialog adds elements that it recognized. Quite on the top you find a locator called "BrowserWindow". It has an attribute "url". Select that attribute.
5.) Click on Paste
6.) In the popup dialog select "GetUrl" and click OK

Thomas

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.