Forum Discussion

Manojrsr's avatar
Manojrsr
Contributor
7 years ago

How to Retrieve Browser Name from External File

I have to retrieve Browser value from CSV File,

In CSV file , Browsername is 14th col (btFirefox), so i used Driver.value(14).

 

How to use browser name in CSV File 

Error Occurs :

The specified browser 'btFirefox' was not found in the collection of the supported browsers. To specify a browser, use either the btIExplorer, btFirefox, btChrome or btEdge constant, or use the browser's index (zero-based) in the collection. 

 

 

 

I have written script to launch browser.

 

function launchBrowser(page,browser,Driver)
{
Browsers.Item(Driver.Value(14)).Run("AppURL");
page=Sys.Browser().Page("*");
}

 

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    You need to use eval() to convert the string "btFirefox" into the corresponding constant:

    var browserType = eval(Driver.Value(14));
    Browsers.Item(browserType).Run("AppURL");
  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi

     

    From Smartbear document

     


    Item Property (Browsers Objects)

     

    Specifies the browser instance you want to get. A browser can be specified via built-in constant, by the process name or by index within the collection:

    Browsers.Item(btIExplorer).Run()
    Browsers.Item("firefox").Run()
    Browsers.Item(0).Run()

    When specifying a browser via constant, the following values are acceptable:

    Constant Value Description
    btIExplorer -1 Microsoft Internet Explorer.
    btFirefox -2 Mozilla Firefox.
    btChrome -3 Google Chrome.
    btEdge -6 Microsoft Edge.

     


    btIExplorer is const of Test Complete, you can't use it as String value.

    btIExplorer  is equal to -1 If you want use btIExplorer  the you can use -1 instead, sameway for other browsers as mentioned above.

     

     

    In CSV file , Browsername is 14th col (btFirefox), so i used Driver.value(14).

     

    In CSV file , Browsername is 14th col (-2), so i used Driver.value(14).

     

    Reference: https://support.smartbear.com/testcomplete/docs/reference/test-objects/controls/web/general/browsers/item.html

     

    Hope you already know if you want to enter -1 in your excel files then you need add in-front:)