Forum Discussion

nassim's avatar
nassim
Occasional Contributor
13 years ago

Opening a new tab in browser

Hello,

1-I am using Test Complete Version 8.70.727.7 at the time and want to make a new tab in my browser (Chrome Version 17.0.963.56 m). Is there any way to script pressing the combination key ctrl+t? (I am using vb). I tried to record it but nothing would be recorded after I try to record!



2-What if I have more than one browser windows open?

Thank you in advance

2 Replies

  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello Nassim,

    >>Is there any way to script pressing the combination key ctrl+t?

    You can use the Keys action of any Page object for this purpose:



    Sub ChromeNewTab

      ' Open a new tab in Chrome

      Call Sys.Process("chrome").Page("*").Keys("^t")

      ' Open a URL in the new tab

      Call Sys.Process("chrome").ToUrl("http://smartbear.com/")

    End Sub





    >>What if I have more than one browser windows open?

    In TestComplete, all pages opened in all browser windows of Google Chrome belong to one (main) process: Sys.Process("chrome"). To address a particular window displaying the needed URL, you simply need to refer to the corresponding Page object.

    Suppose, we have two browser windows, one displaying http://www.webkit.org/  and another displaying http://www.google.com/ and we need to open a new tab in the first window. Then, the script would be:

     

    Sub ChromeNewTab2

      ' Open a new tab in Chrome

      Call Sys.Process("chrome").Page("http://www.webkit.org/").Keys("^t")

      ' Open a URL in the new tab

      Call Sys.Process("chrome").ToUrl("http://smartbear.com/")

    End Sub



    Regards.