Пример #1
0
        public IXenonBrowser SwitchToWindow(AssertionFunc assertion)
        {
            foreach (var windowHandle in _driver.WindowHandles)
            {
                var switchedWindowDriver       = _driver.SwitchTo().Window(windowHandle);
                var switchedWindowXenonBrowser = new SeleniumXenonBrowser((RemoteWebDriver)switchedWindowDriver);
                if (assertion(new XenonAssertion(switchedWindowXenonBrowser)).Passing)
                {
                    return(switchedWindowXenonBrowser);
                }
            }

            return(new SeleniumXenonBrowser(_driver));
        }
Пример #2
0
        private IXenonBrowser SwitchToWindowWithRetries(AssertionFunc assertion, int attemptNumber)
        {
            const int maxTries = 5;

            foreach (var windowHandle in _driver.WindowHandles)
            {
                var switchedWindowDriver       = _driver.SwitchTo().Window(windowHandle);
                var switchedWindowXenonBrowser = new SeleniumXenonBrowser((RemoteWebDriver)switchedWindowDriver);

                if (assertion(new XenonAssertion(switchedWindowXenonBrowser)).Passing)
                {
                    return(switchedWindowXenonBrowser);
                }
            }

            return(attemptNumber > maxTries
                                ? new SeleniumXenonBrowser(_driver)
                                : SwitchToWindowWithRetries(assertion, ++attemptNumber));
        }