Exemplo n.º 1
0
        void PerformActions(Action <Actions> action)
        {
            var actions = new OpenQA.Selenium.Interactions.Actions(_driver);

            action(actions);
            actions.Perform();
        }
        //an boundary constraint (to prevent the user from observing the future and the past(e.g. before 13.7Ga BC) )
        public void MaxZoom(double lt, double rt, int zoom)
        {
            IWebElement buttonZoomOut = Driver.FindElement(By.Id("buttonZoomOut"));
            Actions actions = new Actions(Driver);

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + lt + "," + rt + ");");

            actions.Build();
            actions.MoveToElement(buttonZoomOut, 0, 0);
            for (int k = 0; k < zoom; k++)
            {
                actions.Click();
            }
            actions.Release();
            actions.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");

            var afterzooml = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var afterzoomr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);

            Assert.IsTrue(afterzooml >= -13700000000.0);
            Assert.IsTrue(afterzoomr <= 0.0);
        }
Exemplo n.º 3
0
        protected void ChooseFirstRowOfLookup(string lookupFullName, string searchCondition = "")
        {
            var byEle = By.Id(string.Format("{0}_LookupBtn", lookupFullName));

            ClickElement(byEle);
            if (!string.IsNullOrEmpty(searchCondition))
            {
                string inputField = string.Format("{0}_Lookup-ConditionManager-SearchCondition0-TextValue", lookupFullName);
                SetFieldValue(inputField, searchCondition);
            }

            byEle = By.Id(string.Format("{0}_Lookup-ConditionManager-Search_label", lookupFullName));
            myDriver.FindElement(byEle).Click();
            byEle = By.XPath(string.Format("//div[@id='{0}_Lookup-Grid']/div[2]/div/div/div/div/div/table/tbody/tr/td[2]",
                                           lookupFullName));
            WaitForElement(byEle);
            var element = myDriver.FindElement(byEle);
            var action  = new OpenQA.Selenium.Interactions.Actions(myDriver);

            action.DoubleClick(element);
            action.Perform();
            byEle = By.Id(string.Format("{0}_Lookup-Dialog", lookupFullName));
            var wait = new WebDriverWait(myDriver, TimeSpan.FromSeconds(DriverDefaultTimeout));

            wait.Until((d) => { return(IsElementVisible(byEle) == false); });
        }
Exemplo n.º 4
0
 protected void MoveToFooter(IWebElement footer)
 {
     Actions actions = new Actions(chrome);
     actions.MoveToElement(footer);
     actions.Perform();
     Thread.Sleep(1000);
 }
Exemplo n.º 5
0
 public static void ZoomBackToNormal()
 {
     Actions zoomBackToNormal = new Actions(Browser.Driver);
     zoomBackToNormal.KeyDown(Keys.Control)
         .SendKeys("0")
         .KeyUp(Keys.Control);
     zoomBackToNormal.Perform();
 }
        public static void CreateInd(TitlesList.EnumAdminLeftBar pageName)
        {
            // ReadOnlyCollection<IWebElement> topBarElements;
            Driver.Wait(2);
            /*Array enumNamesTopBar = Enum.GetNames(typeof(TitlesList.EnumTitlesTopBar));
            int pos = Array.IndexOf(enumNamesTopBar, pageName);
            if (pos > -1)
            {
                topBarElements = Driver.Instance.FindElements(By.ClassName("topbar"));
            }
            else
            {
                topBarElements = Driver.Instance.FindElements(By.ClassName("admin-left-navigation-panel"));
            }*/
             /*  var barElements = Driver.Instance.FindElements(By.ClassName("admin-inner-page-content"));
            int valueOfEnum = (int)pageName;
            // string pageNameString = Enum.GetName(typeof(TitlesList.EnumAdminLeftBar), valueOfEnum).ToString();
            string pageNameString = pageName.ToString();
            pageNameString = pageNameString.Replace('_', ' ');

            foreach (var row in barElements)
            {
                ReadOnlyCollection<IWebElement> links = null;
                //  Driver.NoWait(() => links = row.FindElements(By.LinkText(pageName)));

                links = row.FindElements(By.PartialLinkText("Add new"));
                if (links.Count > 0)
                {
                    links[0].Click();
                }

            }*/
            var link1 = Driver.Instance.FindElement(By.LinkText("Add new"));
            link1.Click();
            Driver.Wait(2);
            var inputs = Driver.Instance.FindElements(By.TagName("input"));
            inputs[0].SendKeys("Test Title");
            inputs[1].SendKeys("Test Id");
            var inputs1 = Driver.Instance.FindElement(By.CssSelector("body>div:nth-child(1)>section >div.admin-pages-content>div.admin-inner-page-content>div>form>fieldset>div:nth-child(2)>div:nth-child(8)>span.k-widget.k-dropdown.k-header.ng-pristine.ng-valid.ng-touched>span>span.k-input.ng-scope"));

            Actions action = new Actions(Driver.Instance);
                   action.MoveToElement(inputs1);
                   action.Perform();
                   action.Click();
            action.Perform();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Action to perform Right Click
        /// </summary>
        /// <param name="element">element to be right clicked</param>
        public static void RightClick(IWebElement element)
        {
            IWebDriver driver = ((OpenQA.Selenium.Internal.IWrapsDriver)element).WrappedDriver;
            var        action = new OpenQA.Selenium.Interactions.Actions(driver);

            action.ContextClick(element);
            action.Perform();
            action.ContextClick().Perform();
        }
Exemplo n.º 8
0
 private static void ClickCategoryTree(string category)
 {
     var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']/parent::*/parent::*"), 5);
     Console.WriteLine(expandNode.GetAttribute("class"));
     var actions = new Actions(driver);
     actions.MoveToElement(expandNode);
     actions.Click();
     actions.Perform();
 }
Exemplo n.º 9
0
 public static void ZoomOut()
 {
     Actions zoomOut = new Actions(Browser.Driver);
     zoomOut.KeyDown(Keys.Control)
         .SendKeys(Keys.Subtract)
         .SendKeys(Keys.Subtract)
         .KeyUp(Keys.Control);
     zoomOut.Perform();
 }
Exemplo n.º 10
0
 public AddVideoPage OpenAddVideoPage()
 {
     var action = new Actions(Starter.WebDriver);
     action.MoveToElement(ContributeButton)
         .Click()
         .MoveToElement(AddVideoLink)
         .Click();
     action.Perform();
     return PageObjects.AddVideoPage;
 }
 public void EditCollateral(String amount)
 {
     Browser.Browser.ClickByXPath("//div[text()='Collateral']");
     IWebElement natAmount = Browser.Browser.Instance.FindElement(By.Id("8_Collateral_CollateralValue_ExternalDiv"));
     Actions action = new Actions(Browser.Browser.Instance);
     action.DoubleClick(natAmount);
     action.Perform();
     Browser.Browser.Instance.FindElement(By.XPath("//form[@class='form-inline editableform']//input[@type='text']")).Clear();
     Browser.Browser.Instance.FindElement(By.XPath("//form[@class='form-inline editableform']//input[@type='text']")).SendKeys(amount);
     Browser.Browser.ClickByXPath("//button[@class='editable-submit ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only EMIRButtonStyle']");
     Browser.Browser.ClickByID("EditValidateButton");
 }
Exemplo n.º 12
0
        public IWebElement GetGenericSquadCheckData()
        {
            var Urllist = new List <Urllist>();

            var Squadsdetail = new List <Squadsdetail>();

            Thread.Sleep(2000);

            var allDivs = driver.FindElements(By.CssSelector(".si-team-info"));

            foreach (var div in allDivs)
            {
                var url = div.GetAttribute("href");


                Urllist.Add(new Urllist {
                    URL = url
                });
                TestContext.Out.WriteLine($"URL: { url } ");
            }
            Urllist.Reverse();

            foreach (var p in Urllist.Skip(1))
            {
                var link = p.URL.ToString();
                driver.Navigate().GoToUrl(link);
                Thread.Sleep(3000);

                var playerd = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[2]/div/div/div/div/section/component/div/div/div/div/div/div[3]/div[1]/span"));
                var action1 = new OpenQA.Selenium.Interactions.Actions(driver);
                ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
                action1.MoveToElement(playerd);
                action1.Perform();
                playerd = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                          .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[2]/div/div/div/div/section/component/div/div/div/div/div/div[3]/div[1]/span")));


                var allDivs1 = driver.FindElements(By.CssSelector(".si-player-details"));
                foreach (var div1 in allDivs1)
                {
                    var playername = div1.FindElement(By.CssSelector(".si-player-name")).Text;

                    var jerseyno = div1.FindElement(By.CssSelector(".si-player-jersey")).Text;
                    Squadsdetail.Add(new Squadsdetail {
                        PlayerName = playername, JersyNo = jerseyno
                    });
                    TestContext.Out.WriteLine($"PlayerName: { playername }  | JersyNo:{jerseyno}");
                }
            }
            CreateXlSheet(Squadsdetail);

            return(null);
        }
        public void EditConfirmation(String amount)
        {
            Browser.Browser.ClickByXPath("//div[text()='Confirmation']");
            IWebElement natAmount = Browser.Browser.Instance.FindElement(By.Id("50_Confirmation_ConfirmationMeans_InternalDiv"));

            Actions action = new Actions(Browser.Browser.Instance);
            action.DoubleClick(natAmount);
            action.Perform();
            Thread.Sleep(1000);
            Browser.Browser.Instance.FindElement(By.XPath("//form[@class='form-inline editableform']//input[@type='text']")).Clear();
            Thread.Sleep(1000);
            Browser.Browser.Instance.FindElement(By.XPath("//form[@class='form-inline editableform']//input[@type='text']")).SendKeys(amount + Keys.Return);
            Thread.Sleep(1000);

            IWebElement submitBtn= Browser.Browser.Instance.FindElement(By.XPath("//button[@type='submit']"));
            action.DoubleClick(submitBtn);
            action.DoubleClick(submitBtn);
            action.Perform();
            Thread.Sleep(10000);

            Browser.Browser.ClickByID("EditValidateButton");
        }
        public void EditClearing(String amount)
        {
            Browser.Browser.ClickByXPath("//div[text()='Clearing']");
            IWebElement natAmount = Browser.Browser.Instance.FindElement(By.Id("60_Clearing_CentralCounterparty_ExternalDiv"));
            IWebElement DateTimeStamp = Browser.Browser.Instance.FindElement(By.Id("60_Clearing_ClearingTimestamp_ExternalDiv"));

            Actions action = new Actions(Browser.Browser.Instance);
            action.DoubleClick(natAmount);
            action.Perform();
            Thread.Sleep(1000);
            Browser.Browser.Instance.FindElement(By.XPath("//form[@class='form-inline editableform']//input[@type='text']")).SendKeys(amount);
            Thread.Sleep(1000);
            Browser.Browser.ClickByXPath("//button[@class='editable-submit ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only EMIRButtonStyle']");
            Thread.Sleep(1000);

            IWebElement submitBtn = Browser.Browser.Instance.FindElement(By.XPath("//button[@type='submit']"));
            action.DoubleClick(submitBtn);
            action.DoubleClick(submitBtn);
            action.Perform();

            Browser.Browser.ClickByID("EditValidateButton");
        }
 public virtual void IfNoObjectInClipboardCtrlVRevertsToBrowserBehaviour() {
     GeminiUrl("home?m1=EmployeeRepository&d1=CreateNewEmployeeFromContact&f1_contactDetails=null");
     WaitForView(Pane.Single, PaneType.Home);
     var home = WaitForCss(".title");
     Actions action = new Actions(br);
     action.DoubleClick(home); //Should put "Home"into browser clipboard
     action.SendKeys(Keys.Control + "c");
     action.Perform();
     Thread.Sleep(500);
     //home.SendKeys(Keys.Control + "c");
     string selector = "input.value";
     var target = WaitForCss(selector);
     Assert.AreEqual("", target.GetAttribute("value"));
     target.Click();
     target.SendKeys(Keys.Control + "v");
     Assert.AreEqual("Home", target.GetAttribute("value"));
 }
Exemplo n.º 16
0
        protected void MoveMainContentSplitter()
        {
            var byEle = By.Id("mainContentDetails_splitter");

            WaitForElement(byEle);
            var element = myDriver.FindElement(byEle);
            var point   = element.Location;

            //LogWriter.Write("x : " + point.X);
            //LogWriter.Write("y : " + point.Y);
            if (point.Y > 300)
            {
                var action = new OpenQA.Selenium.Interactions.Actions(myDriver);
                action.DragAndDropToOffset(element, 0, -150);
                action.Perform();
            }
        }
Exemplo n.º 17
0
        public void MouseActiveLeft(double left, double right, int shift)
        {
            Actions action = new Actions(Driver);

            IWebElement axi = Driver.FindElement(By.Id("axis"));
            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + left + "," + right + ");");
            var before = (Driver as IJavaScriptExecutor).ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var bL = Convert.ToDouble((before as Dictionary<string, object>)["left"]);
            var bR = Convert.ToDouble((before as Dictionary<string, object>)["right"]);

            action.Build();
            action.DragAndDropToOffset(axi, -shift, 0);
            action.Perform();

            var after = (Driver as IJavaScriptExecutor).ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var aL = Convert.ToDouble((after as Dictionary<string, object>)["left"]);
            var aR = Convert.ToDouble((after as Dictionary<string, object>)["right"]);
            Assert.IsTrue(aL > bL && aR > bR);
        }
Exemplo n.º 18
0
        public void ShouldAllowSendingKeyUp()
        {
            driver.Url = javascriptPage;
            IWebElement keysEventInput = driver.FindElement(By.Id("theworks"));

            IAction pressShift = new Actions(driver).KeyDown(keysEventInput, Keys.Shift).Build();

            pressShift.Perform();

            IWebElement keyLoggingElement = driver.FindElement(By.Id("result"));

            string eventsText = keyLoggingElement.Text;

            Assert.IsTrue(keyLoggingElement.Text.EndsWith("keydown"), "Key down should be isolated for this test to be meaningful. Event text should end with 'keydown', got events: " + eventsText);

            IAction releaseShift = new Actions(driver).KeyUp(keysEventInput, Keys.Shift).Build();

            releaseShift.Perform();

            eventsText = keyLoggingElement.Text;
            Assert.IsTrue(keyLoggingElement.Text.EndsWith("keyup"), "Key up event not isolated. Event text should end with 'keyup', got: " + eventsText);
        }
Exemplo n.º 19
0
        public void ShouldAllowSelectingMultipleItems()
        {
            driver.Url = selectableItemsPage;

            IWebElement reportingElement = driver.FindElement(By.Id("infodiv"));

            Assert.AreEqual("no info", reportingElement.Text);

            ReadOnlyCollection <IWebElement> listItems = driver.FindElements(By.TagName("li"));

            IAction selectThreeItems = new Actions(driver).KeyDown(Keys.Control)
                                       .Click(listItems[1])
                                       .Click(listItems[3])
                                       .Click(listItems[5])
                                       .KeyUp(Keys.Control).Build();

            selectThreeItems.Perform();

            Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text);

            // Now click on another element, make sure that's the only one selected.
            new Actions(driver).Click(listItems[6]).Build().Perform();
            Assert.AreEqual("#item7", reportingElement.Text);
        }
        public void ShouldAllowSendingKeysWithLeftShiftPressed()
        {
            driver.Url = javascriptPage;

            IWebElement keysEventInput = driver.FindElement(By.Id("theworks"));

            keysEventInput.Click();

            IAction pressShift = new Actions(driver).KeyDown(Keys.LeftShift).Build();

            pressShift.Perform();

            IAction sendLowercase = new Actions(driver).SendKeys("ab").Build();

            sendLowercase.Perform();

            IAction releaseShift = new Actions(driver).KeyUp(Keys.LeftShift).Build();

            releaseShift.Perform();

            AssertThatFormEventsFiredAreExactly("focus keydown keydown keypress keyup keydown keypress keyup keyup");

            Assert.AreEqual("AB", keysEventInput.GetAttribute("value"));
        }
Exemplo n.º 21
0
        //inner zoom not deeper 4 decimal fraction digits
        public void MinZoomNoMoreFourSigns(double x1, double x2, int zoom)
        {
            IWebElement buttonZoomIn = Driver.FindElement(By.Id("buttonZoomIn"));
            Actions actions = new Actions(Driver);

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + x1 + "," + x2 + ");");

            actions.Build();
            actions.MoveToElement(buttonZoomIn, 0, 0);
            for (int k = 0; k < zoom; k++)
            {
                actions.Click();
            }
            actions.Release();
            actions.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");

            var afterzooml = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var afterzoomr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);
            double aftern = afterzoomr - afterzooml;

            int decimaldigitsl = Counter(afterzooml);
            int decimaldigitsr = Counter(afterzoomr);
            int decimaldigitsn = Counter(aftern);

            Assert.IsTrue(decimaldigitsl <= 4 && decimaldigitsr <= 4);
            Assert.IsTrue(decimaldigitsn <= 4);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Method to click on button and Link
        ///
        /// </summary>
        public void Click(Dictionary<int, string> keyWordDic = null, string data = null)
        {
            try
            {
                _testObject = WaitAndGetElement();
                DateTime startTime = DateTime.Now;
                if (Utility.GetParameter("runbyevents").Equals("true"))
                {
                    switch (Browser.BrowserName.ToLower())
                    {
                        case "ie":
                        case "iexplore":
                            ExecuteScript(_testObject, "arguments[0].click();");
                            try
                            {
                                WaitForObjectNotPresent(Utility.GetVariable("ObjectTimeout"),
                                                             Utility.GetVariable("GlobalTimeout"), keyWordDic);
                            }
                            catch
                            {
                                //Nothing to throw in this case
                            }
                            break;
                        default:
                            _testObject.Click();
                            break;
                    }
                }
                else
                {
                    try
                    {
                        // Perform Shift+Click only if Shift key is passed as Data for action sheet data in case Chrome.
                        if ("Shift".Equals(data, StringComparison.OrdinalIgnoreCase) && Browser.BrowserName.Equals(KryptonConstants.BROWSER_CHROME, StringComparison.OrdinalIgnoreCase))
                        {
                            Actions objAction = new Actions(Driver);

                            objAction = objAction.KeyDown(Keys.Shift).Click(_testObject).KeyUp(Keys.Shift);
                            objAction.Build();
                            objAction.Perform();
                        }
                        else
                        {
                            _testObject.Click();
                        }

                        // Pause here for .5 sec as on mac safari VerifyTextOnPage after this looks at the page click is on and assumes that page has been received from server
                        // find a better way to do this
                        if (Browser.BrowserName.Equals("safari"))
                            Thread.Sleep(2000);
                    }
                    catch (ElementNotVisibleException enve)
                    {
                        try { ExecuteScript(_testObject, "arguments[0].click();"); }
                        catch { throw enve; }

                    }
                    catch (Exception e)
                    {
                        if (e.Message.ToLower().Contains(Exceptions.ERROR_NORESPONSEURL))
                        {
                            _testObject.Click();
                        }
                        else
                        {
                            throw;
                        }
                    }
                }

                //measure total time and raise exception if timeout is more than the allowed limit
                DateTime finishTime = DateTime.Now;
                double totalTime = (finishTime - startTime).TotalSeconds;
                if (keyWordDic != null)
                    foreach (string modifiervalue in keyWordDic.Values)
                    {
                        if (modifiervalue.ToLower().Contains("timeout="))
                        {
                            double timeout = double.Parse(modifiervalue.Split('=').Last());
                            if (totalTime > timeout)
                            {
                                throw new Exception("Page load took " + totalTime.ToString(CultureInfo.InvariantCulture) + " seconds to load against expected time of " + timeout + " seconds.");
                            }
                            Property.Remarks = "Page load took " + totalTime.ToString(CultureInfo.InvariantCulture) + " seconds to load against expected time of " + timeout + " seconds.";
                        }
                    }
            }
            catch (Exception e)
            {
                if (_objDataRow.ContainsKey(KryptonConstants.TEST_OBJECT))
                {
                    KryptonException.Writeexception(e);
                    throw new NoSuchElementException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0067").Replace("{MSG3}", _objDataRow[KryptonConstants.TEST_OBJECT]).Replace("{MSG4}", _objDataRow["parent"]).Replace("{MSG1}", AttributeType).Replace("{MSG2}", Attribute).Replace("{ErrorMsg}", e.Message)); // added by
                }
                throw;
            }
        }
Exemplo n.º 23
0
        static void ToggleNavigationPan()
        {
            var span = driver.FindElement(By.XPath("//div[@id='applicationContainer']//div[@id='/episerver/commerce/catalog_rootContainer']//div[@class='dijit epi-globalToolbar dijitToolbar']//span[@class='dijitReset dijitInline dijitButtonNode']"), 5);

            var actionPan = new Actions(driver);
            actionPan.MoveToElement(span);
            actionPan.Click();
            actionPan.Perform();

            var pin = driver.FindElement(
                By.XPath(
                    "//div[@id='navigation']//div[@class='epi-pinnableToolbar']//div[@class='epi-toolbarGroup epi-toolbarTrailing']/span[2]//span[@class='dijitReset dijitInline dijitButtonNode']"), 5);
            var actionPin = new Actions(driver);
            actionPin.MoveToElement(pin);
            actionPin.Click();
            actionPin.Perform();
        }
Exemplo n.º 24
0
        static void NavigateToNewCatalogUI()
        {
            OpenGlobalMenu();
            Thread.Sleep(2000);
            if (NavigationDropDownIsActive())
            {
                // Open drop down menu
                driver.FindElement(
                    By.XPath(
                        "//div[@id='globalMenuContainer']/div[@class='epi-navigation-accordioncontainer']/div[@class='epi-navigation-container1']/a[@href='#global_more_sub']"), 5)
                    .Click();

                driver.FindElement(
                    By.XPath(
                        "div[@class, 'epi-navigation-more-items-wrapper epi-contextMenu']/a[@href='#global_Commerce_sub']"), 5)
                    .Click();

                OpenGlobalMenu();
            }
            else
            {
                var commerceLink = driver.FindElement(
                    By.XPath(
                        "//div[@id='globalMenuContainer']//div[contains(@class, 'epi-navigation-accordioncontainer')]//div[@class='epi-navigation-container1']//span[text()='Commerce']"), 5);
                var actions = new Actions(driver);
                actions.MoveToElement(commerceLink);
                actions.Click();
                actions.Perform();
            }

            //epi-navigation-container2 div
            //global_Commerce_sub ul
            var catalogLink = driver.FindElement(
                    By.XPath("//div[@id='globalMenuContainer']//div[contains(@class, 'epi-navigation-accordioncontainer')]//div[@class='epi-navigation-container2']//ul[@id='global_Commerce_sub']//a[text()='Catalog']"), 5);
            var actionCatalog = new Actions(driver);
            actionCatalog.MoveToElement(catalogLink);
            actionCatalog.Click();
            actionCatalog.Perform();
        }
Exemplo n.º 25
0
        private static void ExpandCategory(string category)
        {
            var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']//preceding-sibling::span[contains(@class, 'dijitTreeExpando')]"), 5);

            if (expandNode.GetAttribute("class").Contains("dijitTreeExpandoClosed"))
            {
                var actions = new Actions(driver);
                actions.MoveToElement(expandNode);
                actions.Click();
                actions.Perform();
                Thread.Sleep(500);
                while (driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']//preceding-sibling::span[contains(@class, 'dijitTreeExpando')]"), 5).GetAttribute("class").Contains("dijitTreeExpandoLoading"))
                {
                    Thread.Sleep(500);
                }
            }
        }
Exemplo n.º 26
0
 private static void ExpandCatalogRoot()
 {
     var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='Catalog Root']//preceding-sibling::span[contains(@class, 'dijitTreeExpando')]"), 5);
     if (expandNode.GetAttribute("class").Contains("dijitTreeExpandoClosed"))
     {
         var actions = new Actions(driver);
         actions.MoveToElement(expandNode);
         actions.Click();
         actions.Perform();
     }
 }
Exemplo n.º 27
0
 public void Perform() => actions.Perform();
Exemplo n.º 28
0
 public void Type(string text)
 {
     EnsureFocus();
     Actions action = new Actions(this.Driver);
     action.SendKeys(text);
     action.Perform();
 }
Exemplo n.º 29
0
        // Mark this test with TestMethod attribute, if need to check error
        // of mouse move actions in Selenium.
        public void TestGestures_SeleniumMouseMoveError()
        {
            Dictionary<string, object> offset;

            const int startX = 100;
            const int startY = 100;

            Actions action = new Actions(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, startX, startY).Perform();

            for (int i = 0; i < 101; i++)
            {
                GoToUrl();

                action.Build();
                action.ClickAndHold();
                action.MoveByOffset(i, i);
                action.Release();
                action.MoveByOffset(-i, -i);
                action.Perform();

                offset = ExecuteScriptGetJson("return offset;");
                Console.WriteLine("Expected offset ({0}, {1}); Observed offset: ({2}, {3});", i, i, offset["xOffset"], offset["yOffset"]);
            }
        }
Exemplo n.º 30
0
        public void KeysTest()
        {
            List<string> keyComboNames = new List<string>()
            {
                "Control",
                "Shift",
                "Alt",
                "Control + Shift",
                "Control + Alt",
                "Shift + Alt",
                "Control + Shift + Alt"
            };

            List<string> colorNames = new List<string>()
            {
                "red",
                "green",
                "lightblue",
                "yellow",
                "lightgreen",
                "silver",
                "magenta"
            };

            List<List<string>> modifierCombonations = new List<List<string>>()
            {
                new List<string>() { Keys.Control },
                new List<string>() { Keys.Shift },
                new List<string>() { Keys.Alt },
                new List<string>() { Keys.Control, Keys.Shift },
                new List<string>() { Keys.Control, Keys.Alt },
                new List<string>() { Keys.Shift, Keys.Alt },
                new List<string>() { Keys.Control, Keys.Shift, Keys.Alt}
            };

            List<string> expectedColors = new List<string>()
            {
                "rgba(255, 0, 0, 1)",
                "rgba(0, 128, 0, 1)",
                "rgba(173, 216, 230, 1)",
                "rgba(255, 255, 0, 1)",
                "rgba(144, 238, 144, 1)",
                "rgba(192, 192, 192, 1)",
                "rgba(255, 0, 255, 1)"
            };

            bool passed = true;
            string errors = string.Empty;

            driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("keyboard_shortcut.html");
            IWebElement body = driver.FindElement(By.CssSelector("body"));
            Actions actions = new Actions(driver);
            for (int i = 0; i < keyComboNames.Count; i++)
            {
                for (int j = 0; j < modifierCombonations[i].Count; j++)
                {
                    actions.KeyDown(modifierCombonations[i][j]);
                }

                actions.SendKeys("1");
                
                // Alternatively, the following single line of code would release
                // all modifier keys, instead of looping through each key.
                // actions.SendKeys(Keys.Null);
                for (int j = 0; j < modifierCombonations[i].Count; j++)
                {
                    actions.KeyUp(modifierCombonations[i][j]);
                }

                actions.Perform();
                string background = body.GetCssValue("background-color");
                passed = passed && background == expectedColors[i];
                if (background != expectedColors[i])
                {
                    if (errors.Length > 0)
                    {
                        errors += "\n";
                    }

                    errors += string.Format("Key not properly processed for {0}. Background should be {1}, Expected: '{2}', Actual: '{3}'",
                        keyComboNames[i],
                        colorNames[i],
                        expectedColors[i],
                        background);
                }
            }

            Assert.IsTrue(passed, errors);
        }
Exemplo n.º 31
0
        static void scrapeStart(string searchChannel, string searchType, int maxResults)
        {
            IList <IWebElement> propertyRows;
            string propertyRowLocator = "";
            int    noOfProperties     = 0;

            //int propertyCount = 0;
            OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(GV.driver);

            for (int i = 0; i < GV.xpathSearchLabels.Count(); i++)
            {
                if (GV.xpathSearchLabels[i] == "propertyLocator")
                {
                    propertyRowLocator = GV.xpathSearchLocators[i];
                }
            }

            propertyRows   = GV.driver.FindElements(By.XPath(propertyRowLocator));
            noOfProperties = propertyRows.Count();

            for (int i = 0; i < GV.outputScrapedData.Count(); i++)
            {
                if (GV.outputScrapedData.IndexOf(GV.outputScrapedData[i]) != GV.outputScrapedData.LastIndexOf(GV.outputScrapedData[i]))
                {
                    //Only add headers once
                    if (i > 0 && GV.outputScrapedData[i - 1] != GV.outputScrapedData[i])
                    {
                        GV.dupeColumnsStart.Add(i + 1);
                        GV.dupeColumnsCount.Add(GV.outputScrapedData.LastIndexOf(GV.outputScrapedData[i]) - GV.outputScrapedData.IndexOf(GV.outputScrapedData[i]));
                    }
                }
            }


            if (propertyRows.Count() < maxResults)
            {
                maxResults = propertyRows.Count();
            }

            for (int i = 0; i < maxResults; i++)
            {
                //Scroll page
                actions.MoveToElement(propertyRows[i]);
                actions.Perform();
                System.Threading.Thread.Sleep(250); //0.25 seconds

                //Output formatting
                Console.WriteLine("");
                Console.WriteLine(spacerGenerator((i + 1), maxResults, true));

                //Add channel and search type to scraped data
                GV.outputScrapedData.Add(searchChannel);
                GV.outputScrapedData.Add(searchType);

                //Scrape
                for (int j = 0; j < GV.xpathScrapeLocators.Count(); j++)
                {
                    //The '.' is prepended to xpathScrapeLocator so it only searched child elements
                    GV.outputScrapedData.Add(findScrapeFormat(propertyRows[i], "." + GV.xpathScrapeLocators[j], GV.xpathScrapeLabels[j], searchChannel));
                    Console.WriteLine(GV.outputScrapedData[GV.outputScrapedData.Count() - 1]);
                }

                //Count rows and columns
                GV.noRows    = i + 2;                              //+2 for headers and counter 0 start
                GV.noColumns = GV.xpathScrapeLocators.Count() + 2; //+2 for the channel abd searcg type columns

                //Log Current time and date
                GV.scrapedTimeSearched.Add(DateTime.Now);

                //Output formatting
                Console.WriteLine(spacerGenerator(maxResults, noOfProperties, false));
            }
        }
Exemplo n.º 32
0
 public static void doubleClick(this IWebDriver driver, string When, string How)
 {
     IWebElement ele = driver._FindElement(When, How);
     Actions action = new Actions(driver);
     action.DoubleClick();
     action.Perform();
 }
Exemplo n.º 33
0
        private bool SearchRefNum(string refNum)
        {
            try
            {
                string searchCriteriaInput   = "caseCriteria_SearchCriteria";
                string advanceOptionButtonId = "AdvOptions";
                string searchBtnId           = "btnSSSubmit";

                var advanceOptionButton = FindElementIfExists(By.Id(advanceOptionButtonId));
                advanceOptionButton.SendKeys(OpenQA.Selenium.Keys.Enter);
                Thread.Sleep(1000);
                takescreenshot("advance options selected");

                var maskdiv = FindElementIfExists(By.Id("AdvOptionsMask"));
                Console.WriteLine(maskdiv.Displayed);
                Console.WriteLine(driver.Url);

                string spantoClicksel = "#AdvOptionsMask > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > fieldset:nth-child(3) > span:nth-child(1) > span:nth-child(1) > span:nth-child(2)";
                var    spantoclick    = FindElementIfExists(By.CssSelector(spantoClicksel));
                spantoclick.SendKeys(OpenQA.Selenium.Keys.Enter);
                spantoclick.Click();
                Thread.Sleep(1000);
                takescreenshot("span clicked");
                Thread.Sleep(1000);

                string litoclicksel = "#caseCriteria_SearchBy_listbox > li:nth-child(5)";
                var    litoclick    = FindElementIfExists(By.CssSelector(litoclicksel));
                litoclick.SendKeys(OpenQA.Selenium.Keys.Enter);
                Thread.Sleep(1000);
                takescreenshot("li clicked");
                litoclick.Click();
                Thread.Sleep(1000);
                takescreenshot("li clicked1");
                Thread.Sleep(1000);

                //// select Case Criteria Of Case Cross Reference Number
                //var caseCriteria = driver.FindElementByName(caseCriteriaName);
                //var actions = new OpenQA.Selenium.Interactions.Actions(driver).MoveToElement(caseCriteria);
                //actions.Perform();
                //Thread.Sleep(1000);
                //caseCriteria.Clear();
                //caseCriteria.SendKeys("Case Cross-Reference Number");
                //takescreenshot("added case criteria");
                //var caseCriteriahid = driver.FindElementById(caseCriteriaInpId);
                //string js = "arguments[0].style.display='block';";
                //driver.ExecuteScript(js, caseCriteriahid);
                //caseCriteriahid.Clear();
                //caseCriteriahid.SendKeys("CaseCrossReferenceNumber");
                //Thread.Sleep(1000);

                var searhInput = FindElementIfExists(By.Id(searchCriteriaInput));
                searhInput.Clear();
                searhInput.SendKeys(refNum);
                Console.WriteLine(searhInput.Displayed);
                takescreenshot("referrence num added");
                var searchBtn = driver.FindElementById(searchBtnId);
                if (!searchBtn.Displayed)
                {
                    var action = new OpenQA.Selenium.Interactions.Actions(driver).MoveToElement(searchBtn);
                    action.Perform();
                }
                searchBtn.Submit();

                IWait <IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(submit_wait));
                wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
                takescreenshot("after search finiched");
                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Exemplo n.º 34
0
 static void moveToElement(string udaj, string druh)
 {
     Actions akce = new Actions(driver);
     if (udaj == "XPath") akce.MoveToElement(driver.FindElement(By.XPath(udaj)));
     if (udaj == "Id") akce.MoveToElement(driver.FindElement(By.Id(udaj)));
     if (udaj == "LinkText") akce.MoveToElement(driver.FindElement(By.LinkText(udaj)));
     if (udaj == "Name") akce.MoveToElement(driver.FindElement(By.Name(udaj)));
     if (udaj == "TagName") akce.MoveToElement(driver.FindElement(By.TagName(udaj)));
     akce.Perform();
 }
Exemplo n.º 35
0
        public void TestZoomOutMarker()
        {
            GoToUrl();

            IWebElement buttonHelper = Driver.FindElement(By.Id("buttonHelper"));
            IWebElement buttonZoomMarkerOut = Driver.FindElement(By.Id("buttonZoomMarkerOut"));
            Actions actions = new Actions(Driver);

            actions.Build();
            actions.MoveToElement(buttonHelper, 0, 0);
            actions.Click();

            var afterHelper = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var ahl = Convert.ToDouble((afterHelper as Dictionary<string, object>)["left"]);
            var ahr = Convert.ToDouble((afterHelper as Dictionary<string, object>)["right"]);
            double z1 = ahr - ahl;

            actions.MoveToElement(buttonZoomMarkerOut, 0, 0);
            actions.Click();
            actions.Release();
            actions.Perform();

            var afterZoomOutMarker = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azml = Convert.ToDouble((afterZoomOutMarker as Dictionary<string, object>)["left"]);
            var azmr = Convert.ToDouble((afterZoomOutMarker as Dictionary<string, object>)["right"]);
            double z2 = azmr - azml;

            Assert.IsTrue(ahl > azml && ahr < azmr && z1 < z2);
        }
Exemplo n.º 36
0
 /// <summary>
 /// Instructs browser to move to a specific web element
 /// </summary>
 /// <param name="element"></param>
 public static void MoveToElement(IWebElement element)
 {
     var action = new Actions(Instance);
     action.MoveToElement(element);
     action.Perform();
     Wait(TimeSpan.FromSeconds(2));
 }
Exemplo n.º 37
0
        // zoom out
        public void ZoomOut(double l, double r)
        {
            IWebElement buttonZoomOut = Driver.FindElement(By.Id("buttonZoomOut"));
            Actions actions = new Actions(Driver);

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");");
            var beforeZoomOut = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var bzl = Convert.ToDouble((beforeZoomOut as Dictionary<string, object>)["left"]);
            var bzr = Convert.ToDouble((beforeZoomOut as Dictionary<string, object>)["right"]);
            double z1 = bzr - bzl;

            actions.Build();
            actions.MoveToElement(buttonZoomOut, 0, 0);
            actions.Click();
            actions.Release();
            actions.Perform();

            var afterZoomOut = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azl = Convert.ToDouble((afterZoomOut as Dictionary<string, object>)["left"]);
            var azr = Convert.ToDouble((afterZoomOut as Dictionary<string, object>)["right"]);
            double z2 = azr - azl;

            if (z1 <= OneDay(134, 5, 2, 4))
            {
                Assert.IsTrue(z1 <= z2);
            }
            else
            {
                Assert.IsTrue(z1 < z2);
            }
        }
        public static void TrashPost(string title)
        {
            List<IWebElement> linksToClick = Driver.Instance.FindElement(By.Id("the-list")).FindElements(By.TagName("tr")).ToList();

            if (linksToClick.Count > 0)
            {
                Actions action = new Actions(Driver.Instance);
                action.MoveToElement(linksToClick[0]);
                action.Perform();
                Driver.Instance.FindElement(By.ClassName("submitdelete")).Click();
                return;

            }
        }
Exemplo n.º 39
0
        ////inner zoom not deeper 1 day
        public void MinZoomDay(int sYear, int sMonth, int sDay, int eYear, int eMonth, int eDay, double l, int zoom)
        {
            IWebElement buttonZoomIn = Driver.FindElement(By.Id("buttonZoomIn"));
            Actions actions = new Actions(Driver);

            var d = (Driver as IJavaScriptExecutor).ExecuteScript
                        ("return $(\"#axis\").axis(\"getYearsBetweenDates\"," +
                        sYear + "," + sMonth + "," + sDay + "," + eYear + "," + eMonth + "," + eDay + ");");

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setPresent\"," + sYear + "," + sMonth + "," + sDay + ");");

            double betwenDays = Convert.ToDouble(d);
            double r = betwenDays + l;
            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");");

            actions.Build();
            actions.MoveToElement(buttonZoomIn, 0, 0);
            for (int k = 0; k < zoom; k++)
            {
                actions.Click();
            }
            actions.Release();
            actions.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azl = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var azr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);
            double z = azr - azl;

            double d1 = OneDay(1233, 3, 4, 5);
            double d2 = OneDay(23, 8, 17, 18);
            double d3 = OneDay(2005, 11, 1, 2);
            Assert.IsTrue(z >= d1);
            Assert.IsTrue(z >= d2);
            Assert.IsTrue(z >= d3);
        }
Exemplo n.º 40
-1
        public void TestMouse_MoveAndClick_Rectangle()
        {
            GoToUrl();

            IWebElement vc = Driver.FindElement(By.Id("vc"));
            IWebElement button = Driver.FindElement(By.Id("button"));

            var rectCenterX = Convert.ToDouble((Driver as IJavaScriptExecutor).ExecuteScript("return rectCenterX;"));
            var scale = Convert.ToDouble((Driver as IJavaScriptExecutor).ExecuteScript("return scale;"));

            Actions actions = new Actions(Driver);
            // building mouse moves on the virtual canvas element
            actions.Build();
            actions.MoveToElement(vc, vc.Size.Width / 2 + (int)(rectCenterX / scale), vc.Size.Height / 2);
            actions.Click();
            actions.MoveToElement(button, 0, 0);
            actions.Release();
            actions.Perform();

            var res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectMovedIn;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectMovedOut;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectClicked;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
        }
Exemplo n.º 41
-1
 public void Click()
 {
     EnsureFocus();
     Actions action = new Actions(this.Driver);
     action.Click();
     action.Perform();
 }