How to get a browser details using the WebDocument class in Ranorex
File: GetBrowserDetails.UserCode.cs
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Text.RegularExpressions;usingSystem.Drawing;usingSystem.Threading;usingWinForms=System.Windows.Forms;usingRanorex;usingRanorex.Core;usingRanorex.Core.Repository;usingRanorex.Core.Testing;namespaceGlobalProjects{publicpartialclassGetBrowserDetails{privatevoidInit(){Browser("Chrome","https://kodingwindow.com/testapp/");}publicvoidBrowser(stringbname,stringurl){try{Report.Info("Opening the "+bname+" browser");Host.Current.OpenBrowser(url,bname,"",false,true,false,false,false);//true will maximize the browser windowDelay.Seconds(5);WebDocumentwd="/dom[@domain='kodingwindow.com']";Report.Info("Browser Name - "+wd.BrowserName);Report.Info("Browser Version - "+wd.BrowserVersion);Report.Info("Domain - "+wd.Domain);Report.Info("Page Title - "+wd.Browser);Report.Info("Page URL - "+wd.PageUrl);Report.Info("Flavor Name - "+wd.FlavorName);Report.Info("Browser State - "+wd.State);Report.Info("Browser Valid - "+wd.Valid);//Host.Current.CloseApplication(wd,new Duration(0));wd.Close();if(wd.Valid.Equals(false)){Report.Success("Browser closed successfully");}else{Report.Failure("Fail: Unable to close the browser window");}}catch{Report.Failure("Error: Unable to open the browser");}}}}
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.