/// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public DashboardPage ActivateWorkload()
 {
     bool isActivateButtonDisplayed = this.WaitForElement("XPATH", (string)objectRepository.ObjectRepositoryTable["ActivateButton"]);
     if (isActivateButtonDisplayed)
     {
         activateButtonControl = this.FindControlByXPath((string)objectRepository.ObjectRepositoryTable["ActivateButton"]);
         Actions action = new Actions(this.Browser.Driver);
         action.MoveToElement(activateButtonControl).DoubleClick().Perform();
         ImplicitlyWait(5000);
         bool isActivateTrialButtonDisplayed = this.WaitForElement("XPATH", (string)objectRepository.ObjectRepositoryTable["ActivateTrialButton"]);
         if (isActivateTrialButtonDisplayed)
         {
             IWebElement activateTrailButtonControl = this.FindControlByXPath((string)objectRepository.ObjectRepositoryTable["ActivateTrialButton"]);
             action.MoveToElement(activateTrailButtonControl).DoubleClick().Perform();
             ImplicitlyWait(10000);
             return new DashboardPage(this.Browser);
         }
         else
         {
             throw new Exception("Activate Trial Button not found");
         }
     }
     else
     {
         throw new Exception("Activate button not found");
     }
 }
Example #2
1
 public void InPutSearchStringAndPressEnter(string text)
 {
     Actions action = new Actions(TestRunner.Driver);
     action.DoubleClick(SearchInput()).Build().Perform();
     SearchInput().Clear();
     SearchInput().SendKeys(text + OpenQA.Selenium.Keys.Enter);
 }
Example #3
0
        public void TheXTest()
        {
            
            driver = new FirefoxDriver();
            IJavaScriptExecutor js = driver as IJavaScriptExecutor;
            Login u = new Login(driver);
            string login1 = "guest";
            u.get().login(login1, login1).click();//вход на сайт
            driver.FindElement(By.Id("sovzond_widget_SimpleButton_104")).Click();
            Thread.Sleep(5000);
            IWebElement element = driver.FindElement(By.Id("sovzond_widget_SimpleButton_0"));
            var builder = new Actions(driver);
            builder.Click(element).Perform();
            IList<IWebElement> el = driver.FindElements(By.ClassName("svzLayerManagerItem"));
            for (int n = 0; n < el.Count; n++)
            {
                if (el[0].Text != "Google") Assert.Fail("не найден Google");
                if (el[4].Text != "Росреестр") Assert.Fail("не найден Росреестр");
                if (el[5].Text != "OpenStreetMap") Assert.Fail("не найден OpenStreetMap");
                if (el[6].Text != "Топооснова") Assert.Fail("не найден Топооснова");
            }
                IWebElement element1 = driver.FindElement(By.Id("dijit_form_RadioButton_3"));
                builder.Click(element1).Perform();
               
               Thread.Sleep(5000);  
               string h= (string)js.ExecuteScript("return window.portal.stdmap.map.baseLayer.div.id.toString()");


            
        }
        public void ShouldAllowUsersToHoverOverElements()
        {
            driver.Url = javascriptPage;

            IWebElement element = driver.FindElement(By.Id("menu1"));
            if (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Windows))
            {
                Assert.Ignore("Skipping test: Simulating hover needs native events");
            }

            IHasInputDevices inputDevicesDriver = driver as IHasInputDevices;
            if (inputDevicesDriver == null)
            {
                return;
            }

            IWebElement item = driver.FindElement(By.Id("item1"));
            Assert.AreEqual("", item.Text);

            ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.background = 'green'", element);
            //element.Hover();
            Actions actionBuilder = new Actions(driver);
            actionBuilder.MoveToElement(element).Perform();

            item = driver.FindElement(By.Id("item1"));
            Assert.AreEqual("Item 1", item.Text);
        }
        public void ShouldAllowClickingOnFormElements()
        {
            if (!IsNativeEventsEnabled || (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux)))
            {
                Assert.Ignore("Skipping ShouldAllowClickingOnFormElements: Only works with native events on Linux.");
            }

            driver.Url = formSelectionPage;

            ReadOnlyCollection<IWebElement> options = driver.FindElements(By.TagName("option"));

            Actions actionBuider = new Actions(driver);
            IAction selectThreeOptions = actionBuider.Click(options[1])
                .KeyDown(Keys.Shift)
                .Click(options[2])
                .Click(options[3])
                .KeyUp(Keys.Shift).Build();

            selectThreeOptions.Perform();

            IWebElement showButton = driver.FindElement(By.Name("showselected"));
            showButton.Click();

            IWebElement resultElement = driver.FindElement(By.Id("result"));
            Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options.");
        }
Example #6
0
        public void Slider(string Anstext, int target)
        {
            IWebElement slider = webDriver.FindElement(By.XPath("//div[div[div[contains(text(),'" + Anstext + "')]]]//div[contains(@id,'AnswerSlider')]//a"));

            OpenQA.Selenium.Interactions.Actions aa = new OpenQA.Selenium.Interactions.Actions(webDriver);
            aa.DragAndDropToOffset(slider, target, 0).Perform();
        }
        public void ShouldAllowSelectingMultipleItems()
        {
            if (!IsNativeEventsEnabled || (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux)))
            {
                Assert.Ignore("Skipping ShouldAllowSelectingMultipleItems: Only works with native events on Linux.");
            }

            driver.Url = selectableItemsPage;

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

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

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

            Actions actionBuider = new Actions(driver);
            IAction selectThreeItems = actionBuider.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.
            actionBuider.Click(listItems[6]).Build().Perform();
            Assert.AreEqual("#item7", reportingElement.Text);
        }
        public void DragAndDropOnJQueryItems()
        {
            driver.Url = droppableItems;

            IWebElement toDrag = driver.FindElement(By.Id("draggable"));
            IWebElement dropInto = driver.FindElement(By.Id("droppable"));

            // Wait until all event handlers are installed.
            System.Threading.Thread.Sleep(500);

            Actions actionProvider = new Actions(driver);
            actionProvider.DragAndDrop(toDrag, dropInto).Perform();

            string text = dropInto.FindElement(By.TagName("p")).Text;

            DateTime endTime = DateTime.Now.Add(TimeSpan.FromSeconds(15));

            while (text != "Dropped!" && (DateTime.Now < endTime))
            {
                System.Threading.Thread.Sleep(200);
                text = dropInto.FindElement(By.TagName("p")).Text;
            }

            Assert.AreEqual("Dropped!", text);

            IWebElement reporter = driver.FindElement(By.Id("drop_reports"));
            // Assert that only one mouse click took place and the mouse was moved
            // during it.
            string reporterText = reporter.Text;
            Assert.IsTrue(Regex.IsMatch(reporterText, "start( move)* down( move)+ up"));
            Assert.AreEqual(1, Regex.Matches(reporterText, "down").Count, "Reporter text:" + reporterText);
            Assert.AreEqual(1, Regex.Matches(reporterText, "up").Count, "Reporter text:" + reporterText);
            Assert.IsTrue(reporterText.Contains("move"), "Reporter text:" + reporterText);
        }
Example #9
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); });
        }
        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"));

            Actions actionBuider = new Actions(driver);
            IAction selectThreeItems = actionBuider.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.
            actionBuider.Click(listItems[6]).Build().Perform();
            Assert.AreEqual("#item7", reportingElement.Text);
        }
Example #11
0
 public void Hover(Element element)
 {
     var sequenceBuilder = new Actions(selenium);
     var actionSequenceBuilder = sequenceBuilder.MoveToElement((IWebElement) element.Native);
     var action = actionSequenceBuilder.Build();
     action.Perform();
 }
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.integrationqa.com/");

            driver.Manage().Window.Maximize();

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            IWebElement menu = driver.FindElement(By.Id("hs_menu_wrapper_module_13970568219884"));
            Actions builder = new Actions(driver);
            builder.MoveToElement(menu).Build().Perform();

            IList<IWebElement> menuItemsList = menu.FindElements(By.ClassName("hs-menu-item"));

            String[] menuItems = new String[menuItemsList.Count];
            int i = 0;
            foreach (IWebElement menuItem in menuItemsList)
            {
                menuItems[i++] = menuItem.Text;
            }

            //Arrange all the list items in alphabetical order
            IEnumerable<String> orderedMenuList = menuItems.OrderBy(lv_menu => lv_menu).ToList();

            //Display the ordered list
            foreach (var menuItem in orderedMenuList)
            {
                if (menuItem.Length > 0)
                    Console.WriteLine(menuItem);
            }
            Console.ReadKey();
        }
Example #13
0
        private static bool clickRequestCard(ChromeDriver driver, WebDriverWait wait, Random random)
        {
            Boolean success = false;

            try
            {
                if (driver.PageSource.Contains("ui2-button ui2-button-default ui2-button-normal ui2-button-medium util-clearfix J-req-card"))
                {
                    IReadOnlyCollection <IWebElement> elements = driver.FindElementsByXPath("//a[@class='ui2-button ui2-button-default ui2-button-normal ui2-button-medium util-clearfix J-req-card']");
                    if (elements != null && elements.Count > 0)
                    {
                        foreach (IWebElement element in elements)
                        {
                            OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver);
                            actions.MoveToElement(element).Click().Build().Perform();
                            System.Threading.Thread.Sleep(random.Next(1000, 2000));
                        }
                        //Console.Write("[{0}] Clicked. ", elements.Count);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("No Element to click: {0}", ex.Message);
            }
            return(success);
        }
        //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);
        }
        public void DoubleClick()
        {
            LOG.Information("Double clicking on element: {0}", WebElement);
            var action = new OpenQA.Selenium.Interactions.Actions(WebDriver);

            action.DoubleClick(WebElement).Perform();
        }
Example #16
0
        void PerformActions(Action <Actions> action)
        {
            var actions = new OpenQA.Selenium.Interactions.Actions(_driver);

            action(actions);
            actions.Perform();
        }
        public void RightClick()
        {
            LOG.Information("Right clicking on element: {0}", WebElement);
            var action = new OpenQA.Selenium.Interactions.Actions(WebDriver);

            action.ContextClick(WebElement).Perform();
        }
Example #18
0
 protected void MoveToFooter(IWebElement footer)
 {
     Actions actions = new Actions(chrome);
     actions.MoveToElement(footer);
     actions.Perform();
     Thread.Sleep(1000);
 }
Example #19
0
        public clsShiftAdministration VerifyErrorMessages(String ShiftName, String Shortcode, String Start, String Duration, String Currencies)
        {
            var wait = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id=\"ShiftTypeListGrid\"]/div/button")));


            IWebElement element = btnAddShift;
            Actions     actions = new OpenQA.Selenium.Interactions.Actions(PropertiesCollection.driver);

            actions.MoveToElement(element).Perform();

            IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver;

            executor.ExecuteScript("arguments[0].click();", element);


            txtShiftName.SendKeys(ShiftName);
            btnSave.Click();

            Assert.AreEqual(lblErrorShiftShortCodeRequired.Text, "A Short Code is required.");

            txtShortCode.SendKeys(Shortcode);

            btnSave.Click();
            System.Threading.Thread.Sleep(2000);
            Assert.AreEqual(lblErrorShiftNameUnique.Text, "The Shift Name must be unique for the Organisation Group.");


            System.Threading.Thread.Sleep(3000);
            return(new clsShiftAdministration());
        }
        public void MouseOver()
        {
            LOG.Information("Mouse over on element: {0}", WebElement);
            var action = new OpenQA.Selenium.Interactions.Actions(WebDriver);

            action.MoveToElement(WebElement).Perform();
        }
Example #21
0
        public void TestHtml5CanvasDrawing()
        {
            try
            {
                driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/html5canvasdraw.html");

                //Get the HTML5 Canvas Element
                IWebElement canvas = driver.FindElement(By.Id("imageTemp"));
                //Select the Pencil Tool
                SelectElement drawtool = new SelectElement(driver.FindElement(By.Id("dtool")));
                drawtool.SelectByText("Pencil");

                //Create a Action Chain for Draw a shape on Canvas
                Actions builder = new Actions(driver);
                builder.ClickAndHold(canvas).MoveByOffset(10, 50).
                                             MoveByOffset(50, 10).
                                             MoveByOffset(-10, -50).
                                             MoveByOffset(-50, -10).Release().Perform();

                //Get a screenshot of Canvas element after Drawing and compare it to the base version
                Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
                string screenshot = ss.AsBase64EncodedString;
                byte[] screenshotAsByteArray = ss.AsByteArray;
                ss.SaveAsFile(@"c:\tmp\post.png", ImageFormat.Png);
            }
            catch (Exception e)
            {
                Assert.Fail("Test Failed due to exception '" + e.Message + "'");
            }
        }
        public void SetUpForFindElementsAndCreateActionsClass()
        {
            this.textBox = this.MainWindow.FindElement(By.Id("TextBox1"));
            this.button = this.MainWindow.FindElement(By.Id("SetTextButton"));

            this.action = new Actions(this.Driver);
        }
Example #23
0
        internal void Launch(bool mobile, string url = "https://www.bing.com/") {
            Quit();
            _viewModel.ResetProfileCommand.RaiseCanExecuteChanged();

            ChromeDriverService service = ChromeDriverService.CreateDefaultService(App.Folder);
            service.HideCommandPromptWindow = true;

            ChromeOptions options = new ChromeOptions();
            options.AddArgument("start-maximized");
            options.AddArgument("user-data-dir=" + App.Folder + "profile");

            if (mobile)
                options.EnableMobileEmulation("Google Nexus 5");

            try {
                _driver = new ChromeDriver(service, options);
                _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));

                _builder = new Actions(_driver);

                LogUpdate("Launching Chrome " + (mobile ? "Mobile" : "Desktop"), Colors.CadetBlue);

                if (url != null)
                    _driver.Navigate().GoToUrl(url);
            }
            catch (Exception ex) {
                LogUpdate("Error Launching Chrome " + (mobile ? "Mobile" : "Desktop") + "\r\n" + ex.Message, Colors.Red);
                service.Dispose();
            }
        }
        public clsRosterAdministration VerifyErrorMessages(String RosterName, String Pane, String TimeZoneorLocation, String TimeZone, String Location, String People, String Shiftdetails, String Status)
        {
            var wait = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(30));

            //wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id=\"ShiftTypeListGrid\"]/div/button")));
            System.Threading.Thread.Sleep(4000);
            btnAddRoster.Click();
            IWebElement element = btnSave;
            Actions     actions = new OpenQA.Selenium.Interactions.Actions(PropertiesCollection.driver);

            actions.MoveToElement(element).Perform();

            IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver;

            executor.ExecuteScript("arguments[0].click();", element);


            System.Threading.Thread.Sleep(2000);

            Assert.AreEqual(lblErrorRosterNameRequired.Text, "A Roster Name is required.");
            Assert.AreEqual(lblErrorPaneIDRequired.Text, "A Pane is required.");


            System.Threading.Thread.Sleep(3000);
            return(new clsRosterAdministration());
        }
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.seleniummaster.com/");

            driver.Manage().Window.Maximize();

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            IWebElement menu = driver.FindElement(By.Id("menubar"));
            Actions builder = new Actions(driver);
            builder.MoveToElement(menu).Build().Perform();

            IList<IWebElement> menuItemsList = menu.FindElements(By.Id("menu"));
            char[] delim = { '\r', '\n' };
            String[] menuList = menuItemsList[0].Text.Split(delim);

            //Query to orderby all the list items
            IEnumerable<string> orderedMenuList = menuList.OrderBy(lv_menu => lv_menu).ToList();

            //Display the ordered list
            foreach (string menuItem in orderedMenuList)
            {
                if (menuItem.Length > 0)
                    Console.WriteLine(menuItem);
            }
            Console.ReadKey();
        }
Example #26
0
        public void Hover()                                                                               // This function move to element and hover on this one (Adbulin 11:30 18.06.2013)
        {
            Actions     builder      = new OpenQA.Selenium.Interactions.Actions(TestFramework.WebDriver); // Edited 19:21 24.06
            IWebElement hoverElement = TestFramework.FindElement(this);

            builder.MoveToElement(hoverElement).Perform();
            WriteLog.WriteLogToFile("Hovering ..... next - a little delay (1 second)", true);
        }
Example #27
0
 /// <summary>
 /// Mousedown event on the element then hover and hold.
 /// </summary>
 /// <param name="element"></param>
 public static void ClickAndHold(this IWebElement element)
 {
     Actions act = new Actions(Browser.Driver);
     act.MoveToElement(element)
         .ClickAndHold(element)
         .Build()
         .Perform();
 }
Example #28
0
 public HomePage LogOut()
 {
     var actions = new Actions(Starter.WebDriver);
     actions.MoveToElement(_loggedAvatar).Perform();
     Starter.WaitForElementVisible(By.CssSelector("a[data-id='logout']"));
     actions.MoveToElement(_logoutLink).Click().Perform();
     return PageObjects.HomePage;
 }
Example #29
0
 public void Initialize()
 {
     _driver = new FirefoxDriver();
     _actions = new Actions(_driver);
     _driver.Url = "http://www.ramyamlab.com/";
     _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
     _driver.Manage().Window.Maximize();
 }
 public static void ZoomBackToNormal()
 {
     Actions zoomBackToNormal = new Actions(Browser.Driver);
     zoomBackToNormal.KeyDown(Keys.Control)
         .SendKeys("0")
         .KeyUp(Keys.Control);
     zoomBackToNormal.Perform();
 }
Example #31
0
 public static IWebElement AddNewUserActionMenuItem(IWebDriver driver)
 {
     var userMenuUserLink = driver.FindDnnElementByXpath(driver, "//*[@id='ControlActionMenu']/li[3]/a");
     var builder = new Actions(driver);
     var hoverOverUserMenuUserLink = builder.MoveToElement(userMenuUserLink).ClickAndHold();
     //hoverOverUserMenuUserLink.Perform();
     return driver.FindDnnElementByXpath(driver, "//*[@id='ControlActionMenu']/li[3]/ul/li[1]/a");
 }
Example #32
0
        protected void HoverElement(AutomatedElement element)
        {
            Actions builder = new OpenQA.Selenium.Interactions.Actions(driver.driver);

            IWebElement _ELmentToHover = driver.driver.FindElement(element.ByElement);

            builder.MoveToElement(_ELmentToHover).Perform();
        }
Example #33
0
        protected string RightClick(IWebElement element)
        {
            var action = new OpenQA.Selenium.Interactions.Actions(myDriver);

            action.MoveToElement(element).ContextClick(element);
            action.Build().Perform();
            return(null);
        }
        /// <summary>
        /// Click and hold an element
        /// </summary>
        /// <param name="element">Page element</param>
        /// <param name="ms">Number of milliseconds to hold down the click</param>
        public static void ClickLong(this IBrowser browser, PageElement element, int ms)
        {
            var action = new Actions(browser.IWebDriver);

            action.ClickAndHold(browser.Find(element)).Build().Perform();
            Thread.Sleep(ms);
            action.Release(browser.Find(element)).Build().Perform();
        }
 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();
 }
Example #36
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();
 }
        public static void DragAndDrop(int count, int range)
        {

            

            Actions move = new Actions(Browser._Driver);
           // move.DragAndDropToOffset(pricingSider, count, range).Build();
           // move.Perform();
        }
Example #38
0
 public void DragAndDropToElement()
 {
     driver.Url = dragAndDropPage;
     IWebElement img1 = driver.FindElement(By.Id("test1"));
     IWebElement img2 = driver.FindElement(By.Id("test2"));
     Actions actionProvider = new Actions(driver);
     actionProvider.DragAndDrop(img2, img1).Perform();
     Assert.AreEqual(img1.Location, img2.Location);
 }
Example #39
0
 public void NabigateToFaq(IWebDriver driver)
 {
     PageFactory.InitElements(driver, this);
     Actions action = new Actions(driver);
     action.MoveToElement(this.LearnMoreLink).Perform();
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
     wait.Until<bool>((d) => { return this.FaqLink.Displayed; });
     this.FaqLink.Click();
 }
Example #40
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();
        }
Example #41
0
        public clsShiftAdministration AddShiftdetails(String ShiftName, String Shortcode, String Start, String Duration, String Currencies)
        {
            var wait = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id=\"ShiftTypeListGrid\"]/div/button")));


            IWebElement element = btnAddShift;
            Actions     actions = new OpenQA.Selenium.Interactions.Actions(PropertiesCollection.driver);

            actions.MoveToElement(element).Perform();

            IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver;

            executor.ExecuteScript("arguments[0].click();", element);


            txtShiftName.SendKeys(ShiftName);
            txtShortCode.SendKeys(Shortcode);

            btnStartFrom.SendKeys(Start);

            txtDuration.SendKeys(Keys.Control + "a");
            txtDuration.SendKeys(Keys.Control + "{DEL}");

            txtDuration.SendKeys(Duration);

            btnAddCurrency.Click();

            System.Threading.Thread.Sleep(3000);

            Console.WriteLine("The Count of Currencies" + allCurrencies.Count);

            Console.WriteLine("The Count of Checkboxes" + allCheckboxes.Count);

            for (int i = 0; i < allCurrencies.Count; i++)
            {
                if (allCurrencies.ElementAt(i).Text.Equals(Currencies))
                {
                    allCheckboxes.ElementAt(i).Click();
                    break;
                }
            }

            System.Threading.Thread.Sleep(3000);
            btnCurrenciesApplyPopupWindow.Click();
            System.Threading.Thread.Sleep(1000);

            IWebElement element1 = btnSave;

            executor.ExecuteScript("window.scrollBy(0,-200)", element1);
            System.Threading.Thread.Sleep(1000);

            btnSave.Click();
            System.Threading.Thread.Sleep(3000);
            return(new clsShiftAdministration());
        }
Example #42
0
        /// <summary>
        /// Handles the command.
        /// </summary>
        /// <param name="driver">The driver used to execute the command.</param>
        /// <param name="locator">The first parameter to the command.</param>
        /// <param name="value">The second parameter to the command.</param>
        /// <returns>The result of the command.</returns>
        protected override object HandleSeleneseCommand(IWebDriver driver, string locator, string value)
        {
            IWebElement dragElement = this.finder.FindElement(driver, locator);
            IWebElement dropElement = this.finder.FindElement(driver, value);
            Actions actionBuilder = new Actions(driver);
            actionBuilder.DragAndDrop(dragElement, dropElement).Perform();

            return null;
        }
 /// <summary>
 /// Hover mouse above first element, then click on second element
 /// </summary>
 /// <param name="elementToHover">first IWebElement element</param>
 /// <param name="elementToClick">second IWebElement element</param>
 /// <returns></returns>
 public static IWebElement MouseHoverThenClick(this IWebElement elementToHover, IWebElement elementToClick)
 {
     OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(Browser.Driver);
     action.MoveToElement(elementToHover);
     action.MoveToElement(elementToClick);
     action.Click(elementToClick);
     action.Build().Perform();
     return(elementToHover);
 }
        public static void CssMouseOver(IWebDriver driver, string LocaterValue)

        {
            IWebElement element = driver.FindElement(By.CssSelector(LocaterValue));

            ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(); ", element);

            OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(driver);

            action.MoveToElement(element).Perform();
        }
Example #45
0
 internal static void MovetoElement(IWebElement element)
 {
     try
     {
         OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(webDriver);
         action.MoveToElement(element).Perform();
     }
     catch (WebDriverException)
     {
         Wait(TimeSpan.FromSeconds(15));
     }
 }
 /// <summary>
 /// Right click method
 /// </summary>
 /// <param name="element">element which is do right click</param>
 internal static void RClick(IWebElement element)
 {
     try
     {
         OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(webDriver);
         action.ContextClick(element).Perform();
     }
     catch (WebDriverException)
     {
         Wait(TimeSpan.FromSeconds(60));
     }
 }
        public bool clickSearchSubmission()
        {
            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(_webDriver);

            builder.MoveToElement(btnSearchTab)
            .MoveByOffset(30, 0)
            .Click()
            .Build()
            .Perform();
            WaitUtilities.WaitForPostBack(_webDriver);
            return(sClick(btnSubmissionSearch));
        }
Example #48
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);
        }
Example #49
0
        public void HoverElement(Element Element)
        {
            if (driver.BrowserToTest == Browser.IE)
            {
                ((IJavaScriptExecutor)driver.driver).ExecuteScript("arguments[0].scrollIntoView(true);", Element);
            }

            else
            {
                Actions builder = new OpenQA.Selenium.Interactions.Actions(driver.driver);

                builder.MoveToElement(driver.driver.FindElement(Element.ByElement)).Perform();
            }
        }
 public static void HoverElement(this IWebDriver driver, BaseElement baseElement)
 {
     try
     {
         Log.Information("WebElementExtension.Hover..{webElement}", baseElement.ToString());
         var action = new OpenQA.Selenium.Interactions.Actions(driver);
         action.MoveToElement(driver.GetElement(baseElement)).Perform();
     }
     catch (Exception ex)
     {
         Log.Error("WebElementExtension.Hover...{message}  {stacktrace}", ex.Message, ex.StackTrace);
         throw ex;
     }
 }
 public string fileupload(IWebDriver driver, string pageData)
 {
     try
     {
         OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver);
         actions.MoveToElement(driver.FindElement(By.XPath("//div[@class='k-button k-upload-button']")));
         actions.Click();
         actions.Build().Perform();
         Thread.Sleep(24000);
         return("Pass");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Example #52
0
        public void NavigateShiftAdminBeforeSave(string Shiftname)
        {
            var wait = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id=\"ShiftTypeListGrid\"]/div/button")));


            IWebElement element = btnAddShift;
            Actions     actions = new OpenQA.Selenium.Interactions.Actions(PropertiesCollection.driver);

            actions.MoveToElement(element).Perform();

            IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver;

            executor.ExecuteScript("arguments[0].click();", element);
            txtShiftName.SendKeys(Shiftname);
        }
Example #53
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();
            }
        }
Example #54
0
        public clsMainPage_TopbarMenu NavigatetoShiftAdministration()
        {
            System.Threading.Thread.Sleep(3000);
            linkAdmin.Click();
            var wait = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(30));

            IWebElement element = linkShiftAdministration;
            Actions     actions = new OpenQA.Selenium.Interactions.Actions(PropertiesCollection.driver);

            actions.MoveToElement(element).Perform();

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.PartialLinkText("Shift Administration")));

            IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver;

            executor.ExecuteScript("arguments[0].click();", element);

            return(new clsMainPage_TopbarMenu());
        }
        /// <summary>
        /// Wait element to become clickable and Mouse Over an element.
        /// </summary>
        /// <param name="elementFactory">Factory that contains IWebElement that we want to mouse over.</param>
        /// <param name="fullElementName">The name of the element(method name) in page object</param>
        /// <param name="secondsToWait">How many second to wait the element to become clickable. By default is 30 seconds</param>
        /// <param name="FatalORFailed">If the parametter is fatal - the test will stop on missing element error. If this parametter is failed - the test will conntinue on missing element error. By default is set to fatal.</param>
        public void OnMouseOver(Func <IWebElement> elementFactory, string fullElementName, int secondsToWait = 30, string fatalORFailed = "Fatal")
        {
            IWebElement element;

            fullElementName = FullElementName(elementFactory, fullElementName);

            try
            {
                element = elementFactory();
                WaitForElement(secondsToWait, element);
                OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(driver);
                action.MoveToElement(element).Perform();
            }
            catch (Exception ex)
            {
                MissingElement(fullElementName, ex.Message, fatalORFailed);
                return;
            }
        }
Example #56
0
File: WDNav.cs Project: subha9/WDTF
        public static bool PerformDragAndDrop(SearchBy sourceBy, string sourceLocator, SearchBy targetBy, string targetLocator)
        {
            IWebElement source = FindElement(sourceBy, sourceLocator, 10);
            IWebElement target = FindElement(targetBy, targetLocator, 10);

            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(_driver);
            try
            {
                loggerInfo.Instance.Message("Perform Drag and Drop for :  " + "Source:{" + sourceLocator + "}   Destination:{" + targetLocator + "}");
                builder.DragAndDrop(source, target).Build().Perform();
            }
            catch (Exception e)
            {
                Exception exception = new Exception(e.Message);
                loggerInfo.Instance.LogAppErro(exception, "Source:{" + sourceLocator + "}   Destination:{" + targetLocator + "}", LogLevel.Error);
                return(false);
            }
            return(true);
        }
Example #57
0
        public static bool ElementMouseOver(IWebElement targetElement)
        {
            Size currentWinSize = _driver.Manage().Window.Size;

            _driver.Manage().Window.Maximize();
            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(_driver);
            try
            {
                builder.MoveToElement(targetElement).Build().Perform();
                Thread.Sleep(5000);
                _driver.Manage().Window.Size = currentWinSize;
            }
            catch (Exception e)
            {
                // loggerInfo.Instance.Message(e.Message);
                return(false);
            }
            return(true);
        }
Example #58
0
        public void AddImage()
        {
            var buttons = Driver.FindElementsByTagName("button");

            foreach (var item in buttons)
            {
                var xt = item.Text;
                if (item.Text.Contains("Change"))
                {
                    try
                    {
                        OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(Driver);
                        action.MoveToElement(item);
                        item.Click();
                        Thread.Sleep(new TimeSpan(0, 0, 5));

                        IJavaScriptExecutor js = (IJavaScriptExecutor)Driver;
                        string count           = (string)js.ExecuteScript("document.querySelector('input[type=file]').setAttribute('style', 'display:block');");

                        var image = Driver.FindElementByCssSelector("input[type=file]");
                        if (image != null && image.Enabled && image.Displayed)
                        {
                            var x = new ImgRep();
                            x.LoadImages();
                            string imgPath = x.Random();
                            image.SendKeys(imgPath);
                            Thread.Sleep(new TimeSpan(0, 0, 15));
                            Console.WriteLine("img added");
                            // x.Delete(imgPath);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("exception on imnage iploade", ex.Message);
                    }
                    //item.Click();
                }
            }
        }
Example #59
-1
 public void Click()
 {
     EnsureFocus();
     Actions action = new Actions(this.Driver);
     action.Click();
     action.Perform();
 }
Example #60
-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));
        }