Highlighted
Absent Member.. Absent Member..
Absent Member..
951 views

Get current browser and current page

Hi all,

I would kindly ask you for help as I need your advice for the best approach.

 

What I have so far in the Object Repository is: Browser(br1), Page(p1), Link(lnk1), Link(lnk2).

Assuming that I have a scenario that looks like this :

Business component 1 : Browser(br1).Page(p1).Link(lnk1).Click 

Business component 2: Browser(br1).Page(p1).Link(lnk2).Click

 

I would like that the second component to run on the current browser and current page (by passing them from Component 1):

[getCurrentBrowser].[getCurrentPage].Link(lnk2).Click

I don't want the code for [getCurrentBrowser] and [getCurrentPage] to be dependent on Browser/Page Object name ("br1"/"pg1" in my case)

 

I am pretty sure that this scenario is widely used but I couldn't find a proper solution so far.

 

Many thanks in advance!

Alex

 

 

0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

Re: Get current browser and current page

One approach would be this -

Function getcurrentbrowser(name)

Set getcurrentbrowser = Browser("name")

End Function

Similarly for getcurrentpage.

You would have to pass a parameter without which there is no way to identify the browser/page.

There are other ways in descriptive programming, but that would not work for your code since you have all the objects added to the OR already.


Accept as solution/Give Kudos to the author if the piece of information answered/helped you to solve your problem.
All the thoughts here are mine not related to my employer nor anyone.
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Get current browser and current page

Since I'm running the tests with a single browser window\tab, I do the following:

b = "micclass:=Browser"
p = "micclass:=Page"

Browser(b).Page(p).Link(<insert descriptive programming for link here>)
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.