Ejemplo n.º 1
0
        public void Final_()
        {
            //explicit wait for page loads
            //it sets the page load time to the specified amount in the app config, if the system takes less time then its ok otherwise it throws an error
            ObjectRepository.Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(ObjectRepository.Config.GetPageLoadTimeOut());
            //implicit wait for elements
            ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(ObjectRepository.Config.GetElementLoadTimeOut());

            NavigationHelper.NavigateToUrl(ObjectRepository.Config.GetWebsite());
            //supply initial string step 1
            IWebElement destination = ObjectRepository.Driver.FindElement(By.CssSelector("input#fsc-destination-search"));

            destination.SendKeys("O");
            Thread.Sleep(10000);//gets sufficient time to get visible
            //step 2 wait fro autosuggest list
            //using dynamic wait
            var wait = GenericHelper.GetWebdriverWait(TimeSpan.FromSeconds(44));
            //wait logic ; returns a list of Iwebelements cz inside auto suggest we have more than 1 element.
            IList <IWebElement> destinations = wait.Until(GetAllElement(By.XPath("//div[@id='react-autowhatever-fsc-destination-search']/ul[@role='listbox']/child::li")));

            foreach (var item in destinations)
            {
                if (item.Text.Equals("Osaka (Any)"))
                {
                    item.Click();
                }
            }

            ButtonHelper.ClickButton(By.XPath("//*[@id='flights-search-controls-root']/div/div/form/div[3]/button"));
            wait.Until(waitElement(By.XPath("//*[@id='app-root']/div[2]/div[2]/div[1]/div[2]")));
            Console.WriteLine("Best price is : {0}", ButtonHelper.GetButtonText_alt(By.XPath("//*[@id='app-root']/div[2]/div[2]/div[1]/div[2]/button[1]/div/div/span")));
        }
Ejemplo n.º 2
0
        public void Button()
        {
            NavigationHelper.NavigateToUrl(ObjectRepository.Config.GetWebsite());
            LinkHelper.ClickLink(By.XPath("//*[@id='authentication-link' and @class='login']"));
            LinkHelper.ClickLink(By.XPath("//div[@class='Qk3sp3k23b-uqHOY6J1-E']"));
            TextboxHelper.TypeInTextbox(By.XPath("//*[@id='email']"), ObjectRepository.Config.GetUserName());
            TextboxHelper.TypeInTextbox(By.XPath("//*[@id='password']"), ObjectRepository.Config.GetPassword());
            //IWebElement ele = ObjectRepository.Driver.FindElement(By.XPath("//*[@class='bpk-button-IZE-J ProgressionButton__button-3U-H6']"));
            //ele.Click();
            Console.WriteLine("Enabled : {0}", ButtonHelper.IsButonEnabled(By.XPath("//*[@class='bpk-button-IZE-J ProgressionButton__button-3U-H6']")));

            //Console.WriteLine("Label : {0}", ButtonHelper.GetButtonText(By.XPath("//button[@data-testid='login-button']"))); //in this case doesnt wrk but if we had got the value in the span then it would hv worked or in value locator
            Console.WriteLine("Label : {0}", ButtonHelper.GetButtonText_alt(By.XPath("//button[@data-testid='login-button']")));//other way of extracing the text

            ButtonHelper.ClickButton(By.XPath("//*[@class='bpk-button-IZE-J ProgressionButton__button-3U-H6']"));
        }
Ejemplo n.º 3
0
        //last param means  parameter with variable length
        public void PerformAction(string keyword, string locatorType, string locatorValue, params string[] args)
        {
            try
            {
                switch (keyword)
                {
                case "Click":
                    ButtonHelper.ClickButton(GetElementLocator(locatorType, locatorValue));
                    break;

                case "SendKeys":
                    TextboxHelper.TypeInTextbox(GetElementLocator(locatorType, locatorValue), args[0]);
                    break;

                case "Select":
                    ComboboxHelper.SelectElement(GetElementLocator(locatorType, locatorValue), args[0]);
                    break;

                case "WaitForElement":
                    GenericHelper.WaitforWebElementInPage(GetElementLocator(locatorType, locatorValue),
                                                          TimeSpan.FromSeconds(50));
                    break;

                case "Navigate":
                    NavigationHelper.NavigateToUrl(args[0]);
                    break;

                case "GetLinkText":
                    ButtonHelper.GetButtonText(GetElementLocator(locatorType, locatorValue));
                    break;

                case "GetLinkText_alt":
                    ButtonHelper.GetButtonText_alt(GetElementLocator(locatorType, locatorValue));
                    break;

                case "Compare":
                    GenericHelper.GetTextAndCompare(GetElementLocator(locatorType, locatorValue), args[0]);
                    break;

                default:
                    throw new NoSuchKeywordFoundException("Keyword Not Found : " + keyword);
                }
            } catch (Exception e)
            {
                Console.Write("Something went wrong: Keyword" + keyword + ", locator: " + locatorType);
            }
        }
Ejemplo n.º 4
0
        public void TestDynamciWait()
        {
            NavigationHelper.NavigateToUrl("https://www.skyscanner.com.au/");
            ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = (TimeSpan.FromSeconds(1));
            WebDriverWait wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(50)); //after 50sec its going to throw timeout exception

            wait.PollingInterval = TimeSpan.FromMilliseconds(250);                                     //checks the wait logic for any exeptions
            //if we find these exceptions then script doesnt stop it just igores those and continues
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
            wait.Until(waitforSearchbox());
            Console.WriteLine(wait.Until(waitforTitle()));
            IWebElement element = wait.Until(waitElement(By.XPath("//*[@id='fsc-destination-search']")));

            element.SendKeys("Osaka");
            ButtonHelper.ClickButton(By.XPath("//*[@id='flights-search-controls-root']/div/div/form/div[3]/button"));
            wait.Until(waitElement(By.XPath("//*[@id='app-root']/div[2]/div[2]/div[1]/div[2]")));
            Console.WriteLine("Best price is : {0}", ButtonHelper.GetButtonText_alt(By.XPath("//*[@id='app-root']/div[2]/div[2]/div[1]/div[2]/button[1]/div/div/span")));
            //wait.Until(waitforLastElemet()).Click();
            //Console.WriteLine("Title : {0}", wait.Until(waitforpageTitle()));
        }