Hi,
Please let me know how to get the current loaded browser name asap
Regards
Kumar
How to get the current browser name
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to get the current browser name
Hi Kumar!
Use the BrowserName property from the WebDocument class.
example code:
Christian
Ranorex Team
Use the BrowserName property from the WebDocument class.
example code:
WebDocument webDocument = "Path/To/the/browser/DOM"; string browserName = webDocument.BrowserName;Best regards,
Christian
Ranorex Team
Re: How to get the current browser name
Hi Christian,
Thanks for your reply. Is there any other way to identify the browser name without declaring the path in webdocument.
Regards
Kumar
Thanks for your reply. Is there any other way to identify the browser name without declaring the path in webdocument.
Regards
Kumar
Re: How to get the current browser name
Do you have more than one browser open or just a single browser?
Regardless, you can get an IList of all the forms displayed on the host then iterate the list searching for either the only browser or a browser that happens to have context.
Something like this. Keep in mind this is not tested code but an example I just wrote up here:
Regardless, you can get an IList of all the forms displayed on the host then iterate the list searching for either the only browser or a browser that happens to have context.
Something like this. Keep in mind this is not tested code but an example I just wrote up here:
Code: Select all
IList<Ranorex.Form> AllForms = Host.Local.FindChildren<Ranorex.Form>();
foreach (Ranorex.Form ThisForm in AllForms )
{
//here search for the property of the web document to determine if it is the one you want.
//If so break out of the loop and use the ThisForm object as your form.
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to get the current browser name
Sure, for a given web element you can use a RanoreXPath to find its parent/ancestor DOM element and then get the browser name from that element:kumarm100 wrote:Is there any other way to identify the browser name without declaring the path in webdocument.
WebElement webElement; WebDocument doc = webElement.FindSingle<WebDocument>("ancestor-or-self::dom"); string browserName = doc.BrowserName;Regards,
Alex
Ranorex Team
Re: How to get the current browser name
Thank you all for your reply, i will try and get back to you
Re: How to get the current browser name
Hi All,
I was able to check the browser and activate by the following way
webdocument wb = null;
if(wb.pageurl.tostring().contains("Home"))
{
wb.browser.activate();
}
I was able to check the browser and activate by the following way
webdocument wb = null;
if(wb.pageurl.tostring().contains("Home"))
{
wb.browser.activate();
}