public void Click(SeleniumCommandArguments search, TimeSpan timeout, bool waitForNewWindow = false)
        {
            var popupHandler = new NewPopupWindowHandler(webDriver);
            var element      = GetElementInFrame(search, timeout);

            var actions = new Actions(webDriver);

            void click() => actions.MoveToElement(element).Click().Build().Perform();

            try
            {
                click();
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("out of bounds"))
                {
                    ((IJavaScriptExecutor)webDriver).ExecuteScript("arguments[0].scrollIntoView(true);", element);
                    click();
                }
                else
                {
                    throw;
                }
            }

            if (!string.IsNullOrEmpty(search.IFrameSearch?.Value))
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish(waitForNewWindow, timeout);
        }
예제 #2
0
        public string RunScript(string script, TimeSpan timeout = new TimeSpan(), bool waitForNewWindow = false)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);

            PreCheckCurrentWindowHandle();
            script += "; return null;";
            object result = webDriver.JavaScriptExecutor().ExecuteScript(script);

            popupHandler.Finish(waitForNewWindow, timeout);
            return(result?.ToString() ?? string.Empty);
        }
예제 #3
0
        public void Click(AmazonCommandArguments search, TimeSpan timeout, bool waitForNewWindow = false)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);
            var     elem    = GetElementInFrame(search, timeout);
            Actions actions = new Actions(webDriver);

            actions.MoveToElement(elem).Click().Build().Perform();
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish(waitForNewWindow, timeout);
        }
예제 #4
0
        public void PressKey(string keyText, AmazonCommandArguments search, TimeSpan timeout)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);
            var    elem          = GetElementInFrame(search, timeout);
            string convertedText = typeof(Keys).GetFields().Where(x => x.Name.ToLower() == keyText.ToLower()).FirstOrDefault()?.GetValue(null) as string;

            if (convertedText == null)
            {
                throw new ArgumentException($"Wrong key argument '{keyText}' specified. Please use keys allowed by selenium library.");
            }
            elem.SendKeys(convertedText);
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish();
        }
예제 #5
0
        public void CallFunction(string functionName, object[] arguments, string type, AmazonCommandArguments search, TimeSpan timeout)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);

            PreCheckCurrentWindowHandle();
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().Frame(FindElement(search.IFrameSearch.Value, search.IFrameBy.Value, timeout));
            }
            IWebElement element = FindElement(search.Search.Value, search.By.Value, timeout);

            element?.CallFunction(functionName, arguments, type);
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish();
        }
예제 #6
0
        public void Click(SeleniumCommandArguments search, TimeSpan timeout, bool waitForNewWindow = false)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);

            PreCheckCurrentWindowHandle();
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().Frame(FindElement(search.IFrameSearch.Value, search.IFrameBy.Value, timeout));
            }
            IWebElement elem    = FindElement(search.Search.Value, search.By.Value, timeout);
            Actions     actions = new Actions(webDriver);

            actions.MoveToElement(elem).Click().Build().Perform();
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish(waitForNewWindow, timeout);
        }