Ejemplo n.º 1
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Navigate
            driver.NavigateToUrl("http://www.bbc.com");
            driver.Wait(10);

            timer.ExtractPageLoadTime("BBC homepage");

            // Navigate to the hero headline
            driver.ClickElement(driver.FindElement(By.XPath("//*[@rev='hero1|headline']")));

            // Read (some of) the article
            driver.Wait(8);
            driver.ScrollPage(2);
            driver.Wait(2);
            driver.ScrollPage(2);

            timer.ExtractPageLoadTime("BBC article");
        }
Ejemplo n.º 2
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Nagivate to espn
            driver.NavigateToUrl("http://www.espn.com");
            driver.Wait(10);

            // Scroll through the infinite list
            driver.ScrollPage(20);

            timer.ExtractPageLoadTime("ESPN homepage");
        }
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Nagivate to Wikipedia/United_States
            driver.NavigateToUrl("https://en.wikipedia.org/wiki/United_States");
            driver.Wait(5);

            // Scroll a bit
            driver.ScrollPage(12);

            timer.ExtractPageLoadTime("Wikipedia article");
        }
Ejemplo n.º 4
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Nagivate to the Instagram page for the NY public library
            driver.NavigateToUrl("https://www.instagram.com/nypl/");
            driver.Wait(5);

            ScenarioEventSourceProvider.EventLog.ScenarioActionStart("Scroll down page");
            driver.ScrollPage(10);
            ScenarioEventSourceProvider.EventLog.ScenarioActionStop("Scroll down page");

            timer.ExtractPageLoadTime("Instagram account");
        }
Ejemplo n.º 5
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Nagivate to the Instagram page for the NY public library
            driver.NavigateToUrl("https://www.instagram.com/nypl/");
            driver.Wait(5);

            driver.ScrollPage(2);

            // Start the infinite scrolling list by clicking on "load more"
            driver.ClickElement(driver.FindElement(By.XPath("//*[contains(text(), 'Load more')]")));
            driver.Wait(3);

            // Then scroll through it
            driver.ScrollPage(8);

            timer.ExtractPageLoadTime("Instagram account");
        }
Ejemplo n.º 6
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            driver.NavigateToUrl("https://www.muni.cz/");
            driver.Wait(5);

            ScenarioEventSourceProvider.EventLog.ScenarioActionStart("Fill search field");
            driver.TypeIntoField(driver.FindElementByCssSelector(".inp-fix.inp-icon.inp-icon--after input"),
                                 "Software Quality" + Keys.Enter);

            driver.Wait(10);

            ScenarioEventSourceProvider.EventLog.ScenarioActionStart("Click on the first result");
            driver.ClickElement(
                driver.FindElementByCssSelector(".gsc-results.gsc-webResult>.gsc-webResult.gsc-result a.gs-title"));

            timer.ExtractPageLoadTime();
        }
Ejemplo n.º 7
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            driver.Navigate().GoToUrl("http://www.yahoo.com");
            driver.WaitForPageLoad();
            driver.Wait(5);

            timer.ExtractPageLoadTime("Yahoo homepage");

            IWebElement newsLink;

            // Go to the News section
            // There are a number of different layouts currently.  Trying each one in order of observed probability.
            try
            {
                newsLink = driver.FindElement(By.XPath("//a[@href='https://www.yahoo.com/news/']"));
            }
            catch {
                try
                {
                    newsLink = driver.FindElement(By.XPath("//a[@href='https://news.yahoo.com/']"));
                }
                catch
                {
                    // No reliable class or id for the news link, so get the news icon, then find its parent
                    newsLink = driver.FindElementByClassName("IconNews").FindElement(By.XPath(".."));
                }
            }
            driver.ClickElement(newsLink);

            driver.Wait(5);

            // Add a link to a known article
            // This hack is a little unfortunate, as no real user is injecting javascript to create a link, but
            // the overhead of doing this is minimal compared to normal code running on the page, and it allows
            // us to control exactly which article we navigate to, and is consistent for every run
            driver.ExecuteScript(@"
                var newA = document.createElement(""a"");
                newA.href = ""https://www.yahoo.com/tech/microsoft-surface-studio-hands-on-221123426.html"";
                newA.innerHTML = ""Go to a typical news story (This link added by automation)"";
                newA.setAttribute(""id"", ""bet_automationLink"");
                var stream = document.querySelector(""#YDC-Stream"");
                stream.insertBefore(newA, stream.firstChild);
                ");

            // Navigate to the article we added
            driver.Wait(5);
            driver.ClickElement(driver.FindElement(By.Id("bet_automationLink")));

            // Simulate reading it
            driver.Wait(6);
            // Give focus to some element on the page so that PG DN scrolls
            driver.FindElement(By.Id("SideTop-0-CanvasTag-Proxy")).FindElement(By.TagName("a")).SendKeys("");
            driver.ScrollPage(2);
            driver.Wait(6);
            driver.ScrollPage(1);
            driver.Wait(6);

            timer.ExtractPageLoadTime("Yahoo article");

            // Then go back to the news homepage
            driver.Navigate().Back();
        }
Ejemplo n.º 8
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            driver.NavigateToUrl("http://www.yahoo.com");
            driver.Wait(5);

            timer.ExtractPageLoadTime("Yahoo homepage");

            IWebElement newsLink;

            // Go to the News section
            // There are a number of different layouts currently.  Trying each one in order of observed probability.
            try
            {
                // This should cover most of the cases
                newsLink = driver.FindElement(By.LinkText("News"));
            }
            catch
            {
                try
                {
                    newsLink = driver.FindElement(By.XPath("//a[@href='https://www.yahoo.com/news/']"));
                }
                catch
                {
                    try
                    {
                        newsLink = driver.FindElement(By.XPath("//a[@href='https://news.yahoo.com/']"));
                    }
                    catch
                    {
                        // ok fine, let's try finding the news link element with a little more brute force
                        // First get all the anchor elements
                        var anchorElements = driver.FindElementsByXPath("//a");

                        // Filter down the elements to the specific one(s) we are looking for.
                        var newsLinkElements = from elem in anchorElements
                                               let hrefx = elem.GetAttribute("href")
                                                           where hrefx.EndsWith("yahoo.com/news/") || hrefx.EndsWith("news.yahoo.com/")
                                                           select elem;

                        // There should only be one or none.
                        newsLink = newsLinkElements.FirstOrDefault();
                    }
                }
            }

            driver.ClickElement(newsLink);

            driver.Wait(5);

            // Add a link to a known article
            // This hack is a little unfortunate, as no real user is injecting javascript to create a link, but
            // the overhead of doing this is minimal compared to normal code running on the page, and it allows
            // us to control exactly which article we navigate to, and is consistent for every run
            driver.ExecuteScript(@"
                var newA = document.createElement(""a"");
                newA.href = ""https://www.yahoo.com/tech/microsoft-surface-studio-hands-on-221123426.html"";
                newA.innerHTML = ""Go to a typical news story (This link added by automation)"";
                newA.setAttribute(""id"", ""bet_automationLink"");
                var stream = document.querySelector(""#YDC-Stream"");
                stream.insertBefore(newA, stream.firstChild);
                ");

            // Navigate to the article we added
            driver.Wait(5);
            driver.ClickElement(driver.FindElement(By.Id("bet_automationLink")));

            // Simulate reading it
            driver.Wait(6);
            // Give focus to some element on the page so that PG DN scrolls
            driver.FindElement(By.Id("SideTop-0-CanvasTag-Proxy")).FindElement(By.TagName("a")).SendKeys("");
            driver.ScrollPage(2);
            driver.Wait(6);
            driver.ScrollPage(1);
            driver.Wait(6);

            timer.ExtractPageLoadTime("Yahoo article");

            // Then go back to the news homepage
            driver.NavigateBack();
        }