public static int HeightInnerHtml(this IWebDriver webDriver, bool isRefresh = false) { int height = 0; if (isRefresh == false && InfoOfBrowsers.ContainsKey(webDriver)) { height = InfoOfBrowsers[webDriver].HeightInnerHtml; if (height != 0) { return(height); } } string script = "return window.innerHeight"; object outObject = null; webDriver.ExcuteJavascript(script, out outObject); height = Convert.ToInt32(outObject); if (!InfoOfBrowsers.ContainsKey(webDriver)) { InfoOfBrowsers.TryAdd(webDriver, new Models.InfoOfBrowser() { HeightInnerHtml = height }); } else { InfoOfBrowsers[webDriver].HeightInnerHtml = height; } return(height); }
public static Rectangle BrowserInfo(this IWebDriver webDriver, bool isRefresh = false) { Point position; Size size; if (isRefresh == false && InfoOfBrowsers.ContainsKey(webDriver)) { if (InfoOfBrowsers[webDriver].LocationOfBrowserOnScreen != default(Point) && InfoOfBrowsers[webDriver].SizeOfBrowser != default(Size)) { position = InfoOfBrowsers[webDriver].LocationOfBrowserOnScreen; size = InfoOfBrowsers[webDriver].SizeOfBrowser; return(new Rectangle(position, size)); } } position = webDriver.Manage().Window.Position; size = webDriver.Manage().Window.Size; if (!InfoOfBrowsers.ContainsKey(webDriver)) { InfoOfBrowsers.TryAdd(webDriver, new Models.InfoOfBrowser() { LocationOfBrowserOnScreen = position, SizeOfBrowser = size }); } else { InfoOfBrowsers[webDriver].LocationOfBrowserOnScreen = position; InfoOfBrowsers[webDriver].SizeOfBrowser = size; } return(new Rectangle(position, size)); }