How can we check: on which browser the script is running (I will use it while cross browser)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can we check: on which browser the script is running (I will use it while cross browser)
How can we check: on which browser the script is running (I will use it while cross browser). Because i want to perform some specific actions for running browsers
- Labels:
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @dikshika114
Would using the If Browser operation suit?
You could specify the browser to perform the required actions under, also leverage the Else statement afterwards.
Some more information available here : https://support.smartbear.com/testcomplete/docs/app-testing/web/general/cross-browser/checking-curre...
Hope this helps,
Mike
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @mikef
1. We can check the current browser for btEdge, btChrome, btInternetExp, btFirefox. But what about "Safari browser"
Means how can we check the current browser is Safari browser running on CBT. Refer Screenshot
2. When i tried with your suggestion as you shared the links to refer: There is the script mentioned. I used that. It's returning wrong result which is useless for me.
like:
CurrentBrowserCBT = Browsers.CurrentBrowser.Family;
Log.Message(CurrentBrowserCBT); -----------------------Output is -73 and it's same for all like chrome, edge etc..... what it's mean????
if(CurrentBrowserCBT == Browsers.btChrome)
{
Log.Message("Remote Chrome Browser is running.")
Project.Variables.AddVariable("ChromeLocName", "String")
}
else if(CurrentBrowserCBT == Browsers.btEdge)
{
Log.Message("Remote Edge Browser is running.")
}
Can you please share the script for that? (JavaScript)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi and excuse me for delayed reply to your direct message.
If I got your question right, then I can say the following:
-- I assume that you are using TestComplete and consume CBT from within TestComplete;
-- Tests that are running in CBT, sequentially or in parallel, are isolated and have no information about those running in parallel;
-- In order to get a reference to the browser, you may use the code like this:
Browsers.RemoteItem(server, <capabilities>).Run(<url>);
browser = Sys.Browser();
-- To distinguish between local and remote browser you may consider this code:
if (browser.Exists && ('remote' == browser.ObjectIdentifier)) // remote browser
...
else // local browser (or browser does not exist)
...
-- While browser object for remote browser contains the .NativeWebDriverObject property, the code recommended for plain Selenium (e.g. https://stackoverflow.com/questions/35258079/how-to-get-browser-name-using-selenium-webdriver-with-j...) does not work;
-- Considering the above, I think that for remote browser you should get its run-time capabilities accessible via the .Capabilities property and parse them to get the value that you need (e.g. running browser's name).
Hope that the above will help.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
