Forum Discussion
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)
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-java/35263148) 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.
Related Content
- 2 years ago
Recent Discussions
- 3 days ago