Beispiel #1
0
        public static string getDropdowntext(IWebElement elem)
        {
            wait.Until(ExpectedConditions.ElementToBeClickable(elem));
            SelectElement sel = new SelectElement(elem);

            return(sel.SelectedOption.Text);
        }
        public IMN18CPage AddTestInstrument()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));

            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("button[data-number='1'"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("test-instruments-table_length"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("test-instruments-table_length")));
            var el = driver.FindElement(By.Name("test-instruments-table_length"));

            wait.Until(ExpectedConditions.ElementToBeClickable(el.FindElement(By.CssSelector("option[value = '100']")))).Click();

            var listOfTr = wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector("tr[id]")));

            System.Threading.Thread.Sleep(3000);
            foreach (var item in listOfTr)
            {
                if (item.Text.Contains("123") && item.Text.Contains("45") && item.Text.Contains("NaMe") && item.Text.Contains("Other"))
                {
                    item.FindElement(By.TagName("input")).Click();
                    break;
                }
            }
            return(this);
        }
 public LoginPage EnterUserName(string emailAddress)
 {
     Wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#username")));
     UserName.Click();
     UserName.SendKeys(emailAddress);
     return(new LoginPage(driver));
 }
Beispiel #4
0
        public static void WaitForElementToBecomeClickable(IWebDriver driver, IWebElement element)
        {
            DefaultWait <IWebDriver> wait = new DefaultWait <IWebDriver>(driver);

            wait.Timeout         = TimeSpan.FromSeconds(10);
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.Until(ExpectedConditions.ElementToBeClickable(element));
        }
 public LoginPage EnterPassWord(string passwordKey)
 {
     Wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#password")));
     PassWord.Click();
     PassWord.SendKeys(passwordKey);
     PassWord.SendKeys(Keys.Enter);
     return(new LoginPage(driver));
 }
Beispiel #6
0
        public static void selectDropdownValue(IWebElement elem, string ddvalue)
        {
            wait.Until(ExpectedConditions.ElementToBeClickable(elem));
            SelectElement sel = new SelectElement(elem);

            sel.SelectByText(ddvalue);
            Trace.WriteLine(string.Format("Selected Text {0} on dropdown: {1}", ddvalue, elemdesc));
        }
Beispiel #7
0
 public static void sendText(IWebElement elem, string text)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(elem));
     elem.Click();
     elem.Clear();
     elem.SendKeys(text);
     Trace.WriteLine(string.Format("Entered Text {0} on Elelment: {1}", text, elemdesc));
 }
 public static void ElementToBeClickable(this IWebElement element, IWebDriver driver, int timeOut = 10)
 {
     try
     {
         Wait(ExpectedConditions.ElementToBeClickable(element), driver, timeOut);
     }
     catch { Console.WriteLine($"    Element Not Clickable [Locator] : {element.GetLocator()}"); }
 }
        public IMN18CPage ProtectiveBondingConductorToWater(string verifyConductorType)
        {
            ProtectiveBondingWaterConductorVerifiedTypeInputField.Click();
            var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 5));

            wait.Until(ExpectedConditions.ElementToBeClickable(ProtectiveBondingWaterPopup.FindElement(By.CssSelector(string.Format("span[value=\"{0}\"]", verifyConductorType)))));
            ProtectiveBondingWaterPopup.FindElement(By.CssSelector(string.Format("span[value=\"{0}\"]", verifyConductorType))).Click();
            return(this);
        }
Beispiel #10
0
 public IWebElement WaitUntilElementLoad(By target)
 {
     try
     {
         return(webWaiter.Until(ExpectedConditions.ElementToBeClickable(target)));
     }
     catch
     {
         return(null);
     }
 }
Beispiel #11
0
        public ResultPage Search(string text)
        {
            searchMagnifier = driver.FindElement(By.CssSelector(".fusion-main-menu-icon"));
            searchMagnifier.Click();

            searchText = driver.FindElement(By.XPath("//input[@name='s']"));
            searchText.SendKeys(text);
            wait.Until(condition: ExpectedConditions.ElementToBeClickable(By.CssSelector(".fusion-search-submit"))).Click();

            return(new ResultPage(driver));
        }
 public void ClickWhenVisibleCSS(string element, string drivertype = "chrome")
 {
     try
     {
         new WebDriverWait(_webDriver.WebDriver(drivertype), TimeSpan.FromSeconds(10)).Until(
             ExpectedConditions.ElementToBeClickable(_webPage.FindElement(By.CssSelector(element)))).Click();
     }
     catch (StaleElementReferenceException)
     {
         _webPage.FindElement(By.CssSelector(element)).Click();
     }
 }
Beispiel #13
0
 public static void click(this IWebDriver webDriver, IWebElement webElement)
 {
     try
     {
         Thread.Sleep(delaySml);
         (new WebDriverWait(webDriver, TimeSpan.FromSeconds(20))).Until(ExpectedConditions.ElementToBeClickable(webElement));
         webElement.Click();
     }
     catch (StaleElementReferenceException e)
     {
         webElement.Click();
     }
 }
        public void ClickWhenVisible(string element, string strategy = "Id", string drivertype = "chrome")
        {
            var pageObj = _webPage.LocateElement(element, strategy);


            try
            {
                if (!pageObj.Displayed)
                {
                    new WebDriverWait(_webDriver.WebDriver(drivertype), TimeSpan.FromSeconds(10)).Until(
                        ExpectedConditions.ElementToBeClickable(_webPage.FindElement(By.CssSelector(element)))).Click();
                }
                else
                {
                    _webPage.LocateElement(element, strategy).Click();
                }
            }
            catch (StaleElementReferenceException)
            {
                _webPage.LocateElement(element, strategy).Click();
            }
        }
        //Explicit wait
        public static IWebElement WaitForElement(IWebDriver driver, By by)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));

            return(wait.Until(ExpectedConditions.ElementToBeClickable(by)));
        }
Beispiel #16
0
        public void StatNavVisualTesting()
        {
            try
            {
                string _username = TestContext.Parameters.Get("now");
                string _password = TestContext.Parameters.Get("next");
                string url       = TestContext.Parameters.Get("webAppUrl");

                runner      = new ClassicRunner();
                eyes        = new Eyes(runner);
                eyes.ApiKey = "975LpId103DAQlvQO4qrOra9deeNnZysqfEH4i4EZ48JMA110";

                // Start the test by setting AUT's name, window or the page name that's being tested, viewport width and height
                eyes.Open(AppDriver.driver, "StatNav", "Visual_Testing", new Size(800, 600));

                AppDriver.driver.Url = url;
                AppDriver.driver.Manage().Window.Maximize();
                AppDriver.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
                AppDriver.wait = new WebDriverWait(AppDriver.driver, TimeSpan.FromSeconds(70));

                // Visual checkpoint #1 - Check the login page.
                eyes.CheckWindow("StatNav - Login Page");

                StatNav spage = new StatNav();

                AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.Login));

                spage.Login.Click();

                AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSAccount));

                spage.MSAccount.SendKeys(_username);

                AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSconfirm));

                spage.MSconfirm.Click();

                AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSPwd));

                spage.MSPwd.SendKeys(_password);

                AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSconfirm));

                spage.MSconfirm.Click();

                AppDriver.wait.Until(ExpectedConditions.ElementToBeClickable(spage.MSconfirm));

                spage.MSconfirm.Click();

                // Visual checkpoint #2 - Check the app page.
                eyes.CheckWindow("StatNav - Home Page");

                AppDriver.driver.FindElement(By.LinkText("Dashboard")).Click();

                // Visual checkpoint #3 - Check the app page.
                eyes.CheckWindow("StatNav - Dashboard");

                AppDriver.driver.FindElement(By.LinkText("Package Containers")).Click();

                // Visual checkpoint #3 - Check the app page.
                eyes.CheckWindow("StatNav - Package Containers");

                AppDriver.driver.FindElement(By.LinkText("Marketing Asset Packages")).Click();

                // Visual checkpoint #3 - Check the app page.
                eyes.CheckWindow("StatNav - Marketing Asset Packages");

                AppDriver.driver.FindElement(By.LinkText("Iterations")).Click();

                // Visual checkpoint #3 - Check the app page.
                eyes.CheckWindow("StatNav - Iterations");

                AppDriver.driver.FindElement(By.LinkText("Candidates")).Click();

                // Visual checkpoint #3 - Check the app page.
                eyes.CheckWindow("StatNav - Candidates");

                // End the test.
                eyes.CloseAsync();

                AppDriver.driver.FindElement(By.XPath("/html/body/div[1]/div/div[2]/ul[2]/li[2]/a")).Click();
            }
            finally
            {
                //AppDriver.driver.Quit();

                // If the test was aborted before eyes.close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();

                //Wait and collect all test results
                TestResultsSummary allTestResults = runner.GetAllTestResults();
            }
        }
Beispiel #17
0
 public static string getText(IWebElement elem)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(elem));
     return(elem.GetAttribute("value"));
 }
Beispiel #18
0
 public static void waitClick(IWebElement elem)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(elem));
     elem.Click();
     Trace.WriteLine("Clicked Element " + elemdesc);
 }
        public void TestWizzair()
        {
            Locator _ = new Locator();
            string  PointOfDeparture   = "Kyiv";
            string  PointOfDestination = "Copenhagen";

            Assert.IsTrue(WaitUntilDisplayed(_.Departure));

            SetDeparture(_.Departure, PointOfDeparture);
            SetDestination(_.Destination, PointOfDestination);

            FindElement(_.SelectDepartureDate);

            FindElement(_.SelectDepartureDate).Click();
            ElementInvisibility(_.LoadingElement);
            WaitUntilDisplayed(_.AvailableDays);
            _driver.FindElements(_.AvailableDays)[2].Click();
            ElementIsVisible(_.LoadingElement);
            ElementInvisibility(_.LoadingElement);
            FindElement(_.OneWayOnlyLink).Click();
            FindElement(_.OKButton).Click();
            WaitUntilDisplayed(_.SearchButton);
            FindElement(_.SearchButton).Click();

            if (_driver.WindowHandles.Count > 1)
            {
                _driver.SwitchTo().Window(_driver.WindowHandles.First()).Close();
                _driver.SwitchTo().Window(_driver.WindowHandles.Last());
            }

            ElementInvisibility(_.LoadingElement);

            new VerifyRoute(FindElement(_.CurrentRoute).Text, PointOfDeparture, PointOfDestination);
            Assert.IsTrue(WaitUntilDisplayed(_.ShowReturnFlightsLink));
            FindElement(_.ShowPricesLink).Click();

            Assert.IsTrue(WaitUntilDisplayed(_.WizzPlusSection));
            Assert.IsTrue(WaitUntilDisplayed(_.WizzGoSection));
            Assert.IsTrue(WaitUntilDisplayed(_.BasicSection));

            Assert.IsTrue(FindElement(_.WizzPlusSectionPrice).Text.Length > 3);
            Assert.IsTrue(FindElement(_.WizzGoSectionPrice).Text.Length > 3);
            Assert.IsTrue(FindElement(_.BasicSectionPrice).Text.Length > 3);

            WaitUntilDisplayed(_.AvailablePricesButton);
            var availablePricesButton = _driver.FindElements(_.AvailablePricesButton);

            ElementIsVisible(_.CloseButton);
            FindElement(_.CloseButton).Click();

            Actions actions = new Actions(_driver);

            actions.MoveToElement(availablePricesButton[1]).Click(availablePricesButton[1]).Perform();
            _wait.Until(ExpectedConditions.ElementToBeClickable(_.ContinueButton));
            FindElement(_.ContinueButton).Click();
            ElementInvisibility(_.LoadingElement);

            //Uncomment if exist seats choice
            //ElementInvisibility(_.LoadingElement);
            //By RecommendedSeats = By.XPath("//button[contains(text(), 'Accept recommended seats')]");
            //ElementIsVisible(RecommendedSeats);
            //FindElement(RecommendedSeats).Click();

            _driver.Navigate().GoToUrl(_driver.Url);
            ElementIsVisible(_.FirstName);
            SetDataPassenger(_.FirstName, FNamePassenger);
            SetDataPassenger(_.LastName, LNamePassenger);

            ElementInvisibility(_.LoadingElement);
            ElementIsVisible(_.Sex);
            _wait.Until(x => x.FindElement(_.Sex).Enabled);

            FindElement(_.Sex).Click();
            _driver.FindElements(_.AvailableBaggage)[2].Click();

            ElementInvisibility(_.LoadingElement);
            _wait.Until(x => x.FindElement(_.PassengersContinueButton).Enabled);

            new VerifyRoute(FindElement(_.Way).Text, PointOfDeparture, PointOfDestination);

            ElementInvisibility(_.LoadingElement);
            ElementIsVisible(_.PassengersContinueButton);
            FindElement(_.PassengersContinueButton).Click();

            ElementIsVisible(_.SingMode);
            Assert.IsTrue(WaitUntilDisplayed(_.SingMode));
        }
        public void TestRegistration()
        {
            try
            {
                IWebElement newUser = wait.Until(EC.ElementIsVisible(By.LinkText("Kreiraj novog korisnika")));
                if (newUser.Displayed && newUser.Enabled)
                {
                    newUser.Click();
                }
            }
            catch (WebDriverTimeoutException)
            {
                Assert.Fail("Element showing took too long.");
            }

            try
            {
                IWebElement RegisterBtn = driver.FindElement(By.Name("register"));
                if (RegisterBtn.Displayed && RegisterBtn.Enabled)
                {
                    IWebElement form_name = driver.FindElement(By.Name("ime"));
                    if (form_name.Displayed && form_name.Enabled)
                    {
                        form_name.Clear();
                        form_name.SendKeys("Tamara");
                    }

                    IWebElement form_lastname = driver.FindElement(By.Name("prezime"));
                    if (form_lastname.Displayed && form_lastname.Enabled)
                    {
                        form_lastname.Clear();
                        form_lastname.SendKeys("Smiljanić");
                    }

                    IWebElement form_Username = driver.FindElement(By.Name("korisnicko"));
                    if (form_Username.Displayed && form_Username.Enabled)
                    {
                        form_Username.Clear();
                        form_Username.SendKeys("Smiljka1979");
                    }

                    IWebElement form_email = driver.FindElement(By.Name("email"));
                    if (form_email.Displayed && form_email.Enabled)
                    {
                        form_email.Clear();
                        form_email.SendKeys(Test_Data_email);
                    }

                    IWebElement form_phone = driver.FindElement(By.Name("telefon"));
                    if (form_phone.Displayed && form_phone.Enabled)
                    {
                        form_phone.Clear();
                        form_phone.SendKeys("+381695555555");
                    }

                    IWebElement form_state = driver.FindElement(By.Id("zemlja"));
                    if (form_state.Enabled)
                    {
                        SelectElement state = new SelectElement(form_state);
                        state.SelectByValue("ita");
                    }

                    try
                    {
                        IWebElement form_city = wait.Until(EC.ElementToBeClickable(By.XPath("//select[@name='grad']")));
                        {
                            if (form_city.Enabled)
                            {
                                SelectElement city = new SelectElement(form_city);
                                city.SelectByValue("Ancona");
                                System.Threading.Thread.Sleep(4000);
                            }
                        }
                    }
                    catch (WebDriverTimeoutException)
                    {
                        Assert.Fail("Test failed = it took too long for element to show");
                    }

                    IWebElement form_address = driver.FindElement(By.XPath("//div[contains(text(),'Ulica i broj')]//following::input"));
                    if (form_address.Displayed && form_address.Enabled)
                    {
                        form_address.Clear();
                        form_address.SendKeys("Ive Andrica 11");
                    }

                    IWebElement form_sex = driver.FindElement(By.Id("pol_z"));
                    if (form_sex.Displayed && form_sex.Enabled)
                    {
                        form_sex.Click();
                    }

                    IWebElement form_newsletter = driver.FindElement(By.Id("newsletter"));
                    if (form_newsletter.Displayed && form_newsletter.Enabled)
                    {
                        form_newsletter.Click();
                    }

                    RegisterBtn.Click();
                    Assert.Pass();
                }
            }
            catch (WebDriverTimeoutException)
            {
                Assert.Fail();
            }
        }
Beispiel #21
0
        //<Summary>
        // This method waits until UI web element is .
        //This method takes wait time and element to be found as parameter
        //</summary>
        public static void WaitForClickableElement(int seconds, By by)
        {
            WebDriverWait driverWait = new WebDriverWait(Driver.driver, TimeSpan.FromSeconds(seconds));

            driverWait.Until(ExpectedConditions.ElementToBeClickable(by));
        }
Beispiel #22
0
        public IWebElement FindClickableElement(By by)
        {
            IWebElement el = DriverWait.Until(ExpectedConditions.ElementToBeClickable(by));

            return(el);
        }
Beispiel #23
0
        public void TestOrder()
        {
            IWebElement searchQuery = wait.Until(EC.ElementIsVisible(By.Id("search_query_top")));

            if (searchQuery.Enabled)
            {
                searchQuery.SendKeys("faded");
                IWebElement searchButton = wait.Until(EC.ElementToBeClickable(By.Name("submit_search")));
                searchButton.Click();
            }

            IWebElement product = wait.Until(EC.ElementIsVisible(By.LinkText("Faded Short Sleeve T-shirts")));

            if (product.Displayed)
            {
                product.Click();
            }

            IWebElement productQuantity = wait.Until(EC.ElementIsVisible(By.Id("quantity_wanted")));

            if (productQuantity.Enabled)
            {
                productQuantity.Clear();
                productQuantity.SendKeys("2");
            }

            IWebElement productSize = driver.FindElement(By.Id("group_1"));

            if (productSize.Enabled)
            {
                SelectElement size = new SelectElement(productSize);
                size.SelectByText("L");
            }

            IWebElement AddToChartButton = wait.Until(EC.ElementToBeClickable(By.Name("Submit")));

            if (AddToChartButton.Enabled)
            {
                AddToChartButton.Click();
            }


            IWebElement verification = wait.Until(EC.ElementIsVisible(By.ClassName("icon-ok")));

            if (verification.Displayed)
            {
                IWebElement continueShopingBtn = wait.Until(EC.ElementIsVisible(By.ClassName("icon-chevron-left")));
                if (continueShopingBtn.Displayed)
                {
                    continueShopingBtn.Click();
                    Assert.Pass("Test is passed - all elements function");
                }
            }
            else
            {
                Assert.Fail("Test failed - Shoping chart isn't verified");
            }


            System.Threading.Thread.Sleep(6000);
        }
Beispiel #24
0
        public static bool MakeABid()
        {
            var BetsPerPageDropdown = Driver.FindElement(By.XPath("//*[@id='auction-page']/div[1]/div[5]/div/input"));

            wait.Until(ExpectedConditions.ElementToBeClickable(BetsPerPageDropdown));
            BetsPerPageDropdown.Click();

            var NumberOfBetsItems = Driver.FindElements(By.CssSelector(".auction-row-select .dropdown-content.select-dropdown>li"))[4];

            wait.Until(ExpectedConditions.ElementToBeClickable(NumberOfBetsItems));
            NumberOfBetsItems.Click();                                                     //child tag

            Thread.Sleep(3000);

            var rows = Driver.FindElements(By.ClassName("auction-row"));

            for (int i = 0; i < rows.Count; i++)
            {
                if (rows[i].Displayed)
                {
                    bool betId = Int32.TryParse(rows[i].GetAttribute("id").Split('-')[1], out int id);

                    if (rows[i].GetAttribute("data-high-bid-is-mine") == "false" && rows[i].GetAttribute("data-lot-is-mine") == "false") //if i have already bidded for that lot
                    {
                        var price = rows[i].FindElement(By.CssSelector(".ar-hi-bid"));

                        var   highest    = price.Text.Replace("£", "");
                        float highestBid = float.Parse(highest);

                        if (highestBid < 10000)
                        {
                            float newBid = highestBid + 1;

                            var bidButton = rows[i].FindElement(By.ClassName("auction-bid-row"));
                            bidButton.Click();
                            IWebElement BidModalWindow = wait.Until((d) => { return(d.FindElement(By.Id("bidModal"))); });

                            IWebElement ModalInputField = Driver.FindElement(By.Id("userSubmittedBid"));
                            wait.Until(ExpectedConditions.ElementToBeClickable(ModalInputField));
                            ModalInputField.Clear();
                            ModalInputField.SendKeys(newBid.ToString());

                            BidConfirmBid.Click();

                            Thread.Sleep(5000);

                            myTrackerButton.Click();

                            var WatchedButton = Driver.FindElement(By.Id("Watched"));
                            WatchedButton.Click();
                            var IHaveBiddedForButton = Driver.FindElement(By.Id("BiddedOn"));
                            IHaveBiddedForButton.Click();

                            var tiles = Driver.FindElements(By.CssSelector(".card-rotating.effect__click"));

                            for (int j = 0; j < tiles.Count; j++)
                            {
                                var tileID = tiles[j].GetAttribute("id");

                                var tileIDNumber = string.Join("", tileID.ToCharArray().Where(char.IsDigit));

                                int onlyNumber = Int32.Parse(tileIDNumber);

                                if (onlyNumber.Equals(id))
                                {
                                    return(true);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            Console.WriteLine("Bid was successfully created, high bid price was not updated");
                            return(false);
                        }
                    }
                }
                else
                {
                    continue;
                }
            }

            return(false);
        }
Beispiel #25
0
 public void WaitUntilElementIsClickable()
 {
     Wait.Until(ExpectedConditions.ElementToBeClickable(ByLocator));
 }