Browser Object

This object's methods provide information about the browser being used.

Note: When using the Qt edition for applications using the QtWebKit module, the name of this object is SquishBrowserInfo in order to avoid clashes with objects provided by the application itself. So instead of Browser.name, use SquishBrowserInfo.name in test scripts that are being used with the Qt edition. The same applies to the other functions and properties provided by this object.

String Browser.name()

This function returns the name of the browser which is being used for running the test as a string value. Values for common browsers are:

  • "Browser on Mobile Device" – For browsers on mobile devices
  • "Firefox" – For Mozilla Firefox
  • "Google Chrome" – For Google Chrome
  • "Chromium-based Applications (using CEF, Electron, nw.js etc.)" – For Chromium-based applications
  • "Microsoft Internet Explorer" – Microsoft InternetExplorer
  • "Microsoft Edge" – For Microsoft Edge
  • "Opera" – For Opera
  • "Other Browser" – For other browsers
  • "Safari" – For Safari

String Browser.majorVersion()

This function returns the major version of the browser which is being used for running the test as an integer value.

Type Browser.type()

This function returns the type of the browser which is being used for running the test as a number value. The returned type value should be compared to one of the following variables (each stands for the respective browser):

  • Browser.Firefox – Firefox
  • Browser.InternetExplorer – Internet Explorer (Microsoft)
  • Browser.Edge – Microsoft Edge
  • Browser.GoogleChrome – Google Chrome
  • Browser.ChromiumBased – Chromium-based Applications (using CEF, Electron, nw.js etc.)
  • Browser.Mozilla – Mozilla
  • Browser.Safari – Safari (Apple)
  • Browser.Proxy – Proxy

Example:

function main()
{
    // ...

    if (Browser.type() == Browser.InternetExplorer) {
        test.log("Using Internet Explorer!")
    }

    // ...
}

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results