Forum Discussion

hanumantha's avatar
hanumantha
New Contributor
9 years ago

Working on multiple tabs

I am looking for a Vb script code for dealing with multiple tabbed browsing.

1.How to activate a perticular tab?

2.Look at the following code

 

Browsers.Item("chrome").Run("https://www.google.co.in/")
Set pg=Sys.Browser.Page("https://www.google.co.in/")
Set myBtn=pg.NativeWebObject.Find("name", "btnK", "INPUT")
'' Checks if the button exists
If myBtn.Exists Then
  MsgBox "hi"
  myBtn.Click
End If

''the above code successfully seraches for the search button

 

sys.Browser.BrowserWindow(0).Keys("^t")
Sys.Browser.ToUrl("https://www.google.co.in/")
Set GetSelectedTab=Sys.Browser.Page("https://www.google.co.in/")
Set img1=GetSelectedTab.NativeWebObject.Find("name", "btnK", "INPUT")
MsgBox img1.exist         'same google page but button search failes

 

 

'may i know the reason for failure on the second instance?

 

Thanks,

Hanumantha

 

 

 

 

3 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Hanumantha,

     

    The following line opens a tab with the page whose URL you specified:

    Browsers.Item("chrome").Run("https://www.google.co.in/")

    Doesn’t this code work for you?

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    MsgBox img1.exist         'same google page but button search failes

    This looks like a typo - it should be Exists with an "s" at the end.