Exemplo n.º 1
11
 /// <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");
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public void ClickPageTitle()
 {
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#form_title_div>div>h1")));
     Actions action = new Actions(driver);
     action.MoveToElement(elem).ClickAndHold().Build().Perform();
     Thread.Sleep(1000);
     action.MoveToElement(elem).Release().Build().Perform();
 }
Exemplo n.º 4
0
 /// <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 void ClickActivitiesAddButton()
 {
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("FormTitle"))).Click();
     IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("Subgrid_Activities_addImageButtonImage")));
     Actions action = new Actions(driver);
     action.MoveToElement(elem).ClickAndHold().Build().Perform();
     Thread.Sleep(1000);
     action.MoveToElement(elem).Release().Build().Perform();
 }
Exemplo n.º 6
0
        public static void FigureChose(int link)
        {
            var hover = Driver.Instance.FindElements(By.CssSelector("div.figure img"))[link];
            var elementToClick = Driver.Instance.FindElement(By.CssSelector("div.figcaption a"));
            //hover odglumiti

            Actions action = new Actions(Driver.Instance);
            action.MoveToElement(hover).Perform();
            action.MoveToElement(elementToClick).Click().Perform();
        }
Exemplo n.º 7
0
        public void ClickBondTenancyRequestRibbonButton()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
            IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("Node_nav_rta_tenancy_rta_tenancy_request")));
            Actions action = new Actions(driver);
            action.MoveToElement(elem).ClickAndHold().Build().Perform();
            Thread.Sleep(1000);
            action.MoveToElement(elem).Release().Build().Perform();

            RefreshPageFrame.RefreshPage(driver, frameId);
        }
Exemplo n.º 8
0
        public void ClickAllContributionsElement()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
            IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div/a/h2[contains(.,'All Contributors')]")));

            Actions action = new Actions(driver);
            action.MoveToElement(elem).ClickAndHold().Build().Perform();
            Thread.Sleep(1000);
            action.MoveToElement(elem).Release().Build().Perform();
            Thread.Sleep(2000);
        }
        public void ClickDeactivateButton()
        {
            this.driver.SwitchTo().DefaultContent();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
            IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[alt='Deactivate']")));
            Actions action = new Actions(driver);
            action.MoveToElement(elem).ClickAndHold().Build().Perform();
            Thread.Sleep(1000);
            action.MoveToElement(elem).Release().Build().Perform();
        }
 public void ClickCreateButton()
 {
     this.driver.SwitchTo().DefaultContent();
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("navTabGlobalCreateImage")));
     Actions action = new Actions(driver);
     action.MoveToElement(elem).ClickAndHold().Build().Perform();
     Thread.Sleep(2000); //Temporary
     action.MoveToElement(elem).Release().Build().Perform();
     Thread.Sleep(1000);
 }
Exemplo n.º 11
0
 public void ClickActivityListItem(string activity)
 {
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     IWebElement parent = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("tblItems")));
     IWebElement elem = parent.FindElement(By.XPath("//*[contains(text(),'" + activity + "')]"));
     Actions action = new Actions(driver);
     action.MoveToElement(elem).Build().Perform();
     Thread.Sleep(1000);
     action.MoveToElement(elem).ClickAndHold().Build().Perform();
     Thread.Sleep(2000);
     action.MoveToElement(elem).Release().Build().Perform();
 }
Exemplo n.º 12
0
        public static void ClearTextBoxValue(string elementId, IWebDriver d)
        {
            WebDriverWait wait = new WebDriverWait(d, TimeSpan.FromSeconds(waitsec));
            IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#" + elementId + ">div")));
            Actions actions = new Actions(d);
            actions.MoveToElement(elem,0,0).Click().Build().Perform();

            Thread.Sleep(500);
            IWebElement el = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(elementId + "_i")));
            actions.MoveToElement(elem, 0, 0).Click().Build().Perform();
            el.Clear();
            el.SendKeys(Keys.Backspace);
        }
        public void ClickUnsavedChangesButton()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
            IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("savefooter_statuscontrol")));

            Actions action = new Actions(driver);
            Thread.Sleep(2000);
            action.MoveToElement(elem).ClickAndHold().Build().Perform();
            Thread.Sleep(2000);
            action.MoveToElement(elem).Release().Build().Perform();
            Thread.Sleep(2000);
            WaitForPageToLoad.WaitToLoad(driver);
        }
Exemplo n.º 14
0
 public void ClickDeactivateIMG()
 {
     RefreshPageFrame.RefreshPage(driver, frameId);
     driver.SwitchTo().DefaultContent();
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[alt='Deactivate']")));
     Thread.Sleep(2000);
     Actions action = new Actions(driver);
     action.MoveToElement(driver.FindElement(By.CssSelector("img[alt='Deactivate']"))).ClickAndHold().Build().Perform();
     Thread.Sleep(2000);
     action.MoveToElement(driver.FindElement(By.CssSelector("img[alt='Deactivate']"))).Release().Build().Perform();
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[alt='Activate']")));
     driver.SwitchTo().Frame(frameId);
 }
Exemplo n.º 15
0
        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();
        }
Exemplo n.º 16
0
 public void Hover(Element element)
 {
     var sequenceBuilder = new Actions(selenium);
     var actionSequenceBuilder = sequenceBuilder.MoveToElement((IWebElement) element.Native);
     var action = actionSequenceBuilder.Build();
     action.Perform();
 }
Exemplo n.º 17
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());
        }
Exemplo n.º 18
0
        //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.º 19
0
        public void MouseOver()
        {
            LOG.Information("Mouse over on element: {0}", WebElement);
            var action = new OpenQA.Selenium.Interactions.Actions(WebDriver);

            action.MoveToElement(WebElement).Perform();
        }
Exemplo n.º 20
0
 protected void MoveToFooter(IWebElement footer)
 {
     Actions actions = new Actions(chrome);
     actions.MoveToElement(footer);
     actions.Perform();
     Thread.Sleep(1000);
 }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
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);
        }
        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());
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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();
 }
        /*
           * These methods are for the messages that appear on top of the home page
           * They might not be present  all the time.
           * The find element methods are surrounded by try catch so that the script doesn't fail when the elements are not found
           */
        /*
           * EmailWarningButton This button is always shown on top of FirstRunDialogueFramePageModel Buttoncancel and should be clicked first
           * ************************************************************************
           */
        public void ClickBeginButton()
        {
            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                IWebElement parent = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("crmDialogFooter")));
                IWebElement elem = parent.FindElement(By.Id("butBegin"));
                Actions action = new Actions(driver);
                action.MoveToElement(elem).ClickAndHold().Build().Perform();
                Thread.Sleep(2000);
                action.MoveToElement(elem).Release().Build().Perform();
            }
            catch
            {

            }
        }
Exemplo n.º 28
0
        protected string RightClick(IWebElement element)
        {
            var action = new OpenQA.Selenium.Interactions.Actions(myDriver);

            action.MoveToElement(element).ContextClick(element);
            action.Build().Perform();
            return(null);
        }
Exemplo n.º 29
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");
 }
Exemplo n.º 30
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();
        }
Exemplo n.º 31
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());
        }
Exemplo n.º 32
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.º 33
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();
 }
 public static void Lang()
 {
     Actions build = new Actions(Drivers.Driver);
     var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(5));
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div.r.links")));
     Actions man = build.MoveToElement(Drivers.Driver.FindElement(By.Id("dLang")));
     man.Build().Perform();
     Actions rus = man.MoveToElement(Drivers.Driver.FindElement(By.LinkText("Русский")));
     rus.Click().Perform();
 }
Exemplo n.º 35
0
		public void DeletePost(string messageText)
		{
			Trace.WriteLine(TraceLevelComposite + "Delete the Post:");

			Trace.WriteLine(TraceLevelPage + "Make the Delete button to appear:");
			Actions builder = new Actions(_driver);
			IWebElement element = WaitForElement(By.XPath("//div[@class = 'journalitem']/p[text() = '" + messageText + "']"));
			builder.MoveToElement(element).Perform();

			Trace.WriteLine(TraceLevelPage + "Move mouse to displayed Delete button and Click on it:");
			WaitForElement(By.XPath("//div[@id = 'journalItems']//div[@class = 'minidel']")).WaitTillVisible().WaitTillEnabled();
			builder.MoveToElement(
				FindElement(By.XPath("//div[@id = 'journalItems']/div[div[@class = 'journalitem']/p[text() = '" + messageText + "']]/div[@class = 'minidel']"))).
				Click().Build().Perform();

			Trace.WriteLine(TraceLevelPage + "Click on 'Yes' buton to confirm delete:");
			WaitForConfirmationBox(15);
			ClickYesOnConfirmationBox();
		}
Exemplo n.º 36
0
 public AddVideoPage OpenAddVideoPage()
 {
     var action = new Actions(Starter.WebDriver);
     action.MoveToElement(ContributeButton)
         .Click()
         .MoveToElement(AddVideoLink)
         .Click();
     action.Perform();
     return PageObjects.AddVideoPage;
 }
Exemplo n.º 37
0
        public void RandomRedirectTest()
        {
            BaseTest.BaseUrl = RandomPage.HomePageUrl;
            BaseTest.Setup(BaseTest.BaseUrl);

            WebDriverWait wait = new WebDriverWait(BaseTest.BaseDriver, TimeSpan.FromSeconds(5));
            wait.Until((d) => { return d.Title.StartsWith("RANDOM.ORG - Integer Generator"); });

            // select how many rand numbers
            Assert.IsTrue(RandomPage.NumbersCountInput.Displayed);
            RandomPage.NumbersCountInput.Clear();
            RandomPage.NumbersCountInput.SendKeys("1");
            // select range
            Assert.IsTrue(RandomPage.MinNumbersInput.Displayed);
            // clear min
            RandomPage.MinNumbersInput.Clear();
            RandomPage.MinNumbersInput.SendKeys("1");

            Assert.IsTrue(RandomPage.MaxNumbersInput.Displayed);
            // clear max
            RandomPage.MaxNumbersInput.Clear();
            RandomPage.MaxNumbersInput.SendKeys("2");

            Assert.IsTrue(RandomPage.GetNumbersBtn.Displayed);
            RandomPage.GetNumbersBtn.Click();

            Thread.Sleep(1000);

            String randNum = RandomPage.GeneratedNumber.Text;

            if (randNum == "2 ")
            {
                GoForTwo();
            }
            else if (randNum == "1 ")
            {
                Assert.IsTrue(RandomPage.LearnMoreLink.Displayed);

                Actions action = new Actions(BaseTest.BaseDriver);
                action.MoveToElement(RandomPage.LearnMoreLink).MoveToElement(RandomPage.LearnMoreNavLink).Click().Build().Perform();

                //Assert.IsTrue(RandomPage.LearnMoreNavLink.Displayed);
                //RandomPage.LearnMoreNavLink.Click();
                Assert.AreEqual("RANDOM.ORG - Frequently Asked Questions (FAQ)", BaseTest.BaseDriver.Title);

                GoForTwo();
            }
            else
            {
                throw new IndexOutOfRangeException("Generated number is not correct!");
            }

            BaseTest.TearDown();
        }
Exemplo n.º 38
0
        public static void SafeClick(this IWebElement element, IWebDriver driver)
        {
            if (element.Displayed && element.Enabled)
            {
                Actions builder = new Actions(driver);
                var action = builder.MoveToElement(element, 0, -170);
                action.Perform();

                action.Click(element).Build().Perform();
            }
        }
Exemplo n.º 39
0
        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();
        }
Exemplo n.º 40
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));
     }
 }
        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));
        }
Exemplo n.º 42
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 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;
     }
 }
Exemplo n.º 44
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();
            }
        }
Exemplo n.º 45
0
 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);
     }
 }
Exemplo n.º 46
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);
        }
Exemplo n.º 47
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());
        }
Exemplo n.º 48
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);
        }
        /// <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;
            }
        }
Exemplo n.º 50
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();
                }
            }
        }
Exemplo n.º 51
0
 /// <summary>
 /// Hover mouse above the element
 /// </summary>
 /// <param name="element">element to hove mouse over</param>
 /// <returns></returns>
 public static IWebElement MouseHover(this IWebElement element, int timeOut = 1)
 {
     OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(Browser.Driver);
     action.MoveToElement(element).Build().Perform();
     return(element);
 }
        public clsRosterAdministration AddRosterdetails(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=\"RosterMaintenanceGrid\"]/div/button")));
            IWebElement element = btnAddRoster;
            Actions     actions = new OpenQA.Selenium.Interactions.Actions(PropertiesCollection.driver);

            actions.MoveToElement(element).Perform();
            IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver;

            executor.ExecuteScript("arguments[0].click();", element);
            txtRosterName.SendKeys(RosterName);
            System.Threading.Thread.Sleep(5000);
            wait.Until(ExpectedConditions.ElementToBeClickable(drpdwnPane));
            drpdwnPane.Click();
            IList <IWebElement> options = PropertiesCollection.driver.FindElements(By.XPath("//ul[@id='PaneID_listbox']/li"));

            System.Threading.Thread.Sleep(5000);
            // Loop through the options and select the one that matches

            for (int i = 0; i < options.Count; i++)
            {
                if (options.ElementAt(i).Text.Equals(Pane))
                {
                    wait.Until(ExpectedConditions.ElementToBeClickable(options.ElementAt(i)));
                    options.ElementAt(i).Click();
                    break;
                }
            }

            System.Threading.Thread.Sleep(2000);
            btnAddPeople.Click();
            System.Threading.Thread.Sleep(2000);
            wait.Until(ExpectedConditions.ElementToBeClickable(txtPeopleSelection));
            txtPeopleSelection.SendKeys(People);
            System.Threading.Thread.Sleep(2000);
            chkSelectAll.Click();
            btnApplyPeopleWindow.Click();
            System.Threading.Thread.Sleep(10000);
            btnAddshift.Click();

            System.Threading.Thread.Sleep(8000);
            for (int i = 0; i < allShiftNames.Count; i++)
            {
                if (allShiftNames.ElementAt(i).Text.Equals(Shiftdetails))
                {
                    allchkboxes.ElementAt(i).Click();
                    break;
                }
            }

            wait.Until(ExpectedConditions.ElementToBeClickable(btnApplyShiftTypeWindow));
            System.Threading.Thread.Sleep(8000);
            btnApplyShiftTypeWindow.Click();
            System.Threading.Thread.Sleep(3000);
            IWebElement element1 = btnSave;

            executor.ExecuteScript("window.scrollBy(0,-200)", element1);
            Actions a = new Actions(PropertiesCollection.driver);

            a.MoveToElement(btnSave).Perform();
            wait.Until(ExpectedConditions.ElementToBeClickable(btnSave));
            btnSave.Click();
            System.Threading.Thread.Sleep(3000);
            return(new clsRosterAdministration());
        }
Exemplo n.º 53
0
 public IMouseActions MoveToElement(BaseElement toElement)
 {
     actions.MoveToElement(toElement.IWebElement);
     return(this);
 }
 public static void To(IWebDriver driver, IWebElement locator)
 {
     Act.Actions _action = new Act.Actions(driver);
     _action.MoveToElement(locator).Perform();
 }
Exemplo n.º 55
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.º 56
-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));
        }