Example #1
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Get the relevant username and password
            UserInfo credentials = credentialManager.GetCredentials("powerbi.com");

            // Navigate and log in
            driver.Navigate().GoToUrl("http://app.powerbi.com");
            driver.Wait(5);

            driver.ClickElement(driver.FindElement(By.XPath("//*[@data-event-property='signin']")));
            driver.Wait(5);

            driver.TypeIntoField(driver.FindElementById("cred_userid_inputtext"), credentials.Username);
            driver.Wait(1);

            driver.TypeIntoField(driver.FindElementById("cred_password_inputtext"), credentials.Password);
            driver.Wait(1);
            driver.Keyboard.SendKeys(Keys.Enter);
            driver.Wait(5);

            // Click into Gross Margin %
            driver.ClickElement(driver.FindElement(By.XPath("//*[@data-id='2423882']")).FindElement(By.ClassName("inFocusTileBtn")));
            driver.Wait(10);

            // Back to dashboard
            driver.ClickElement(driver.FindElement(By.XPath("//*[contains(text(), 'Exit Focus mode')]")).FindElement(By.XPath("..")));
            driver.Wait(3);

            // Click into Total Revenue
            driver.ClickElement(driver.FindElement(By.XPath("//*[@data-id='2423887']")).FindElement(By.ClassName("inFocusTileBtn")));
            driver.Wait(10);

            // Back to dashboard
            driver.ClickElement(driver.FindElement(By.XPath("//*[contains(text(), 'Exit Focus mode')]")).FindElement(By.XPath("..")));
        }
        private void LogIn(RemoteWebDriver driver, CredentialManager credentialManager)
        {
            // Get the relevant username and password
            UserInfo credentials = credentialManager.GetCredentials("gmail.com");

            try
            {
                // Enter username
                driver.TypeIntoField(driver.FindElementById("Email"), credentials.Username + Keys.Enter);
                driver.Wait(1);
            }
            catch (ElementNotVisibleException) { }
            catch (InvalidOperationException)
            {
                // If using profiles, the Email element will not be found and user will be able to enter the password
            }

            // Enter password
            driver.TypeIntoField(driver.FindElementById("Passwd"), credentials.Password + Keys.Enter);

            // give the page some time to load
            driver.Wait(14);

            // Check the url to make sure login was successful
            if (driver.Url != @"https://mail.google.com/mail/u/0/#inbox" && driver.Url != @"https://mail.google.com/mail/#inbox")
            {
                throw new Exception("Login to Gmail failed!");
            }
        }
Example #3
0
        private void LogIn(RemoteWebDriver driver, CredentialManager credentialManager)
        {
            // Get the relevant username and password
            UserInfo credentials = credentialManager.GetCredentials("gmail.com");

            try
            {
                // Enter username
                driver.TypeIntoField(driver.FindElementById("Email"), credentials.Username);
                driver.Wait(1);

                // Tab down and hit next button
                driver.Keyboard.SendKeys(Keys.Tab);
                driver.Keyboard.SendKeys(Keys.Enter);

                driver.Wait(1);
            }
            catch (ElementNotVisibleException)
            {
                // If using profiles, the Email element will not be found and user will be able to enter the password
            }

            // Enter password
            driver.TypeIntoField(driver.FindElementById("Passwd"), credentials.Password);

            // Tab down and hit submit button
            driver.Keyboard.SendKeys(Keys.Tab);
            driver.Wait(1);
            driver.Keyboard.SendKeys(Keys.Enter);
        }
Example #4
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            driver.NavigateToUrl("http://www.facebook.com");
            driver.Wait(5);

            UserInfo credentials = credentialManager.GetCredentials("facebook.com");

            // if not logged on, log on
            var elems = driver.FindElements(By.CssSelector("H2"));

            driver.Wait(2);

            var username = driver.FindElement(By.Id("email"));
            var password = driver.FindElement(By.Id("pass"));

            driver.TypeIntoField(username, credentials.Username);
            driver.Wait(1);

            driver.TypeIntoField(password, credentials.Password + Keys.Enter);
            driver.Wait(1);

            // Check to makes sure the login was successful
            if (driver.Title == "Log into Facebook | Facebook")
            {
                throw new Exception("Login to Facebook failed!");
            }

            // Once we're logged in, all we're going to do is scroll through the page
            // We're simply measuring a user looking through their news feed for a minute
            driver.Wait(5);
            driver.ScrollPage(20);
        }
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            driver.NavigateToUrl("http://www.facebook.com");
            driver.Wait(5);

            UserInfo credentials = credentialManager.GetCredentials("facebook.com");

            string[] titles =
            {
                "Log into Facebook | Facebook",
                "Facebook – log in or sign up",
                "Facebook — войдите или зарегистрируйтесь"
            };

            if (titles.Contains(driver.Title))
            {
                Logger.LogWriteLine("    Starting logging into Facebook...");
                ScenarioEventSourceProvider.EventLog.AccoungLogInStart("Facebook");

                // if not logged on, log on
                var elems = driver.FindElements(By.CssSelector("H2"));
                driver.Wait(2);

                var username = driver.FindElement(By.Id("email"));
                var password = driver.FindElement(By.Id("pass"));

                username.Clear();
                username.Clear();

                driver.TypeIntoField(username, credentials.Username);
                driver.Wait(1);

                driver.TypeIntoField(password, credentials.Password + Keys.Enter);
                driver.Wait(1);

                ScenarioEventSourceProvider.EventLog.AccoungLogInStop("Facebook");
                Logger.LogWriteLine("    Completed logging into Facebook...");
            }
            else
            {
                Logger.LogWriteLine("    Already logged into Facebook...");
            }

            // Check to makes sure the login was successful
            if (titles.Contains(driver.Title))
            {
                throw new Exception("Login to Facebook failed!");
            }

            // Once we're logged in, all we're going to do is scroll through the page
            // We're simply measuring a user looking through their news feed for a minute
            driver.Wait(5);
            driver.ScrollPage(20);
        }
Example #6
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager)
        {
            UserInfo credentials = credentialManager.GetCredentials("outlook.com");

            // Navigate
            driver.Navigate().GoToUrl("http://www.outlook.com");
            driver.Wait(5);

            // Log in
            driver.TypeIntoField(driver.FindElementById("i0116"), credentials.Username + Keys.Enter);
            driver.Wait(1);

            driver.TypeIntoField(driver.FindElementById("i0118"), credentials.Password + Keys.Enter);
            driver.Wait(5);

            // Cycle through some emails, simply with the down arrow key
            for (int i = 0; i < 5; i++)
            {
                driver.Keyboard.SendKeys(Keys.Down);
                driver.Wait(5);
            }

            // Compose a new email and send to a test account
            driver.ClickElement(driver.FindElement(By.XPath("//*[@title='Write a new message (N)']")));
            driver.Wait(3);

            driver.TypeIntoField("*****@*****.**" + Keys.Tab);
            driver.Wait(3);

            driver.TypeIntoField(driver.FindElement(By.XPath("//*[@aria-label='Subject,']")), "Subject" + Keys.Tab);
            driver.Wait(3);

            driver.TypeIntoField(driver.FindElement(By.XPath("//*[@aria-label='Message body']")), "This is a message.");
            driver.Wait(1);

            // Send the message with ctrl + Enter shortcut
            driver.Keyboard.PressKey(Keys.Control);
            driver.Keyboard.SendKeys(Keys.Enter);
            driver.Keyboard.ReleaseKey(Keys.Control);
            driver.Wait(5);

            // Arrow back up to the top
            for (int i = 0; i < 5; i++)
            {
                driver.Keyboard.SendKeys(Keys.Up);
                driver.Wait(2);
            }
        }
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            // Get the relevant username and password
            UserInfo credentials = credentialManager.GetCredentials("azure.com");

            // Go to the login
            driver.Navigate().GoToUrl("http://portal.azure.com");
            driver.Wait(3);

            // Log in
            driver.TypeIntoField(driver.FindElementById("cred_userid_inputtext"), credentials.Username);
            driver.TypeIntoField(driver.FindElementById("cred_password_inputtext"), credentials.Password + Keys.Enter);
            driver.Wait(8);

            // Open a blade
            var sidebar = driver.FindElementByClassName("fxs-sidebar-bar");

            driver.ClickElement(sidebar.FindElement(By.XPath("//*[@title='All resources']")));
            driver.Wait(10);

            // Open the marketplace
            driver.ClickElement(sidebar.FindElement(By.ClassName("fxs-sidebar-browse")));
            driver.Wait(2);

            driver.TypeIntoField(driver.FindElement(By.ClassName("fxs-sidebar-filter-input")), "marketplace" + Keys.Enter);
            driver.Wait(12);

            // Search for Visual studio
            driver.TypeIntoField(driver.FindElementByClassName("ext-gallery-search-container").FindElement(By.ClassName("azc-input")), "Visual studio" + Keys.Enter);
            driver.Wait(10);

            // Open more blades
            driver.ClickElement(sidebar.FindElement(By.XPath("//*[@title='Billing']")));
            driver.Wait(10);

            driver.ClickElement(sidebar.FindElement(By.XPath("//*[@title='Resource groups']")));
            driver.Wait(10);

            driver.ClickElement(sidebar.FindElement(By.XPath("//*[@title='App Services']")));
            driver.Wait(10);

            driver.ClickElement(sidebar.FindElement(By.XPath("//*[@title='SQL databases']")));
            driver.Wait(10);

            driver.ClickElement(sidebar.FindElement(By.XPath("//*[@title='Virtual machines']")));
            driver.Wait(10);
        }
Example #8
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            UserInfo credentials = credentialManager.GetCredentials("pinterest.com");

            // Nagivate to the Pintrest explore page
            driver.Navigate().GoToUrl("https://www.pinterest.com/");
            driver.Wait(5);

            // Log in
            driver.TypeIntoField(driver.FindElement(By.Name("id")), credentials.Username);
            driver.Wait(2);
            driver.TypeIntoField(driver.FindElement(By.Name("password")), credentials.Password + Keys.Enter);
            driver.Wait(8);

            // Scroll
            driver.ScrollPage(10);
        }
        private void LogIn(RemoteWebDriver driver, CredentialManager credentialManager)
        {
            string startingPageTitle = driver.Title;

            // If an account is not already logged in, the page title will be simply 'Gmail'
            if (startingPageTitle.Equals("Gmail", StringComparison.InvariantCultureIgnoreCase))
            {
                // Get the relevant username and password
                UserInfo credentials = credentialManager.GetCredentials("gmail.com");

                Logger.LogWriteLine("    Starting logging into Gmail...");

                ScenarioEventSourceProvider.EventLog.AccoungLogInStart("Gmail");
                try
                {
                    // Enter username
                    driver.TypeIntoField(driver.FindElement(By.XPath("//input[@type='email']")), credentials.Username + Keys.Enter);
                    driver.Wait(1);
                }
                catch (ElementNotVisibleException) { }
                catch (InvalidOperationException)
                {
                    // If using profiles, the Email element will not be found and user will be able to enter the password
                }

                // Enter password
                driver.TypeIntoField(driver.FindElement(By.XPath("//input[@type='password']")), credentials.Password + Keys.Enter);

                // give the page some time to load
                driver.Wait(14);

                // Check the url to make sure login was successful
                if (driver.Url != @"https://mail.google.com/mail/u/0/#inbox" && driver.Url != @"https://mail.google.com/mail/#inbox")
                {
                    throw new Exception("Login to Gmail failed!");
                }

                ScenarioEventSourceProvider.EventLog.AccoungLogInStop("Gmail");
                Logger.LogWriteLine("    Completed logging into Gmail...");
            }
            else
            {
                Logger.LogWriteLine("    Already logged into Gmail...");
            }
        }
Example #10
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            UserInfo credentials = credentialManager.GetCredentials("office.com");

            // Navigate
            driver.NavigateToUrl("http://www.office.com");
            driver.Wait(5);

            // Click on "Sign In" button
            driver.ClickElement(driver.FindElementByLinkText("Sign in"));
            driver.Wait(2);

            // Log in
            driver.TypeIntoField(driver.FindElementById("cred_userid_inputtext"), credentials.Username + Keys.Tab);
            driver.Wait(8);
            driver.TypeIntoField(driver.FindElementByName("passwd"), credentials.Password + Keys.Enter);
            driver.Wait(5);
        }
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager)
        {
            UserInfo credentials = credentialManager.GetCredentials("facebook.com");

            // First tab
            driver.Navigate().GoToUrl(backgroundUrls[0]);
            driver.Wait(30);

            driver.ExecuteScript("window.open();");
            driver.SwitchTo().Window(driver.WindowHandles[driver.WindowHandles.Count - 1]);

            // Second tab
            driver.Navigate().GoToUrl(backgroundUrls[1]);
            driver.Wait(30);

            driver.ExecuteScript("window.open();");
            driver.SwitchTo().Window(driver.WindowHandles[driver.WindowHandles.Count - 1]);

            // Third tab (Facebook)
            driver.Navigate().GoToUrl(backgroundUrls[2]);
            driver.Wait(3);

            // ...Log in
            driver.TypeIntoField(driver.FindElement(By.Id("email")), credentials.Username);
            driver.TypeIntoField(driver.FindElement(By.Id("pass")), credentials.Password + Keys.Enter);

            driver.Wait(30);

            driver.ExecuteScript("window.open();");
            driver.SwitchTo().Window(driver.WindowHandles[driver.WindowHandles.Count - 1]);

            // Fourth tab | The loop
            for (int i = 0; i < 100; i++)
            {
                foreach (string url in urls)
                {
                    driver.Navigate().GoToUrl(url);
                    driver.Wait(30);
                }
            }
        }
Example #12
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            UserInfo credentials = credentialManager.GetCredentials("office.com");

            // Navigate
            driver.NavigateToUrl("https://outlook.live.com/owa/?nlp=1");
            driver.Wait(5);

            // Log in
            driver.TypeIntoField(driver.FindElementById("i0116"), credentials.Username + Keys.Enter);
            driver.Wait(1);

            driver.TypeIntoField(driver.FindElementById("i0118"), credentials.Password + Keys.Enter);
            driver.Wait(10);

            // Go to office
            driver.ClickElement(driver.FindElementByClassName("o365cs-nav-button"));
            driver.ClickElement(driver.FindElementById("O365_AppTile_ShellPowerPointOnline"));
            driver.Wait(8);

            // That opens up a new tab, so we have to give Webdriver focus in the new tab
            driver.SwitchTo().Window(driver.WindowHandles[driver.WindowHandles.Count - 1]);
            driver.Wait(1);

            // Open up a  doc
            driver.ClickElement(driver.FindElementById("mruitem_0"));
            driver.Wait(6);

            // This next section is in an iframe, so we have to switch to the iframe to access content in it
            driver.SwitchTo().Frame(driver.FindElement(By.Id("sdx_ow_iframe")));

            // Edit the document
            driver.ClickElement(driver.FindElementById("PptUpperToolbar.LeftButtonDock.FlyoutPptEdit-Medium20"));
            driver.Wait(1);
            driver.ClickElement(driver.FindElementById("PptUpperToolbar.LeftButtonDock.FlyoutPptEdit.EditInWebApp-Menu32"));
            driver.Wait(6);
            driver.ScrollPage(2);
        }
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager)
        {
            UserInfo credentials = credentialManager.GetCredentials("outlook.com");

            // Navigate
            driver.Navigate().GoToUrl("http://www.outlook.com");
            driver.Wait(5);

            // Log in
            driver.TypeIntoField(driver.FindElementById("i0116"), credentials.Username + Keys.Enter);
            driver.Wait(1);

            driver.TypeIntoField(driver.FindElementById("i0118"), credentials.Password + Keys.Enter);
            driver.Wait(10);

            // Go to office
            driver.ClickElement(driver.FindElementByClassName("o365cs-nav-button"));
            driver.ClickElement(driver.FindElementById("O365_AppTile_ShellWordOnline"));
            driver.Wait(8);

            // That opens up a new tab, so we have to give Webdriver focus in the new tab
            driver.SwitchTo().Window(driver.WindowHandles[driver.WindowHandles.Count - 1]);
            driver.Wait(1);

            // Open up a Word doc
            driver.ClickElement(driver.FindElementById("mruitem_0"));
            driver.Wait(6);

            // This next section is in an iframe, so we have to switch to the iframe to access content in it
            driver.SwitchTo().Frame(driver.FindElement(By.Id("sdx_ow_iframe")));

            // Edit the document
            driver.ClickElement(driver.FindElementById("flyoutWordViewerEdit-Medium20"));
            driver.Wait(1);
            driver.ClickElement(driver.FindElementById("btnFlyoutEditOnWeb-Menu32"));
            driver.Wait(6);
            driver.ScrollPage(2);
        }
Example #14
0
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager)
        {
            driver.Navigate().GoToUrl("http://www.facebook.com");
            driver.Wait(5);

            UserInfo credentials = credentialManager.GetCredentials("facebook.com");

            // if not logged on, log on
            var elems = driver.FindElements(By.CssSelector("H2"));

            foreach (IWebElement elem in elems)
            {
                driver.Wait(2);
                var username = driver.FindElement(By.Id("email"));
                var password = driver.FindElement(By.Id("pass"));

                username.Clear();
                driver.TypeIntoField(username, credentials.Username);
                driver.Wait(1);

                password.Clear();
                driver.Wait(3);
                driver.TypeIntoField(password, credentials.Password);
                driver.Wait(1);

                // Avoding applying click to button because of ObscureElement bug in Microsfot Edge with high DPI
                // Instead use tab and enter. Seemed to be pretty reliable across browsers
                driver.Keyboard.SendKeys(Keys.Tab);
                driver.Keyboard.SendKeys(Keys.Enter);
                driver.Wait(2);
                break;
            }

            // Once we're logged in, all we're going to do is scroll through the page
            // We're simply measuring a user looking through their news feed for a minute

            driver.ScrollPage(20);
        }
        public override void Run(RemoteWebDriver driver, string browser, CredentialManager credentialManager, ResponsivenessTimer timer)
        {
            IWebElement notificationWindow = null;
            IWebElement cancelButton       = null;

            driver.NavigateToUrl("http://www.facebook.com");
            driver.Wait(5);

            UserInfo credentials = credentialManager.GetCredentials("facebook.com");

            if (driver.Title == "Log into Facebook | Facebook" || driver.Title == "Facebook - Log In or Sign Up")
            {
                Logger.LogWriteLine("    Starting logging into Facebook...");
                ScenarioEventSourceProvider.EventLog.AccountLogInStart("Facebook");

                // if not logged on, log on
                var elems = driver.FindElements(By.CssSelector("H2"));
                driver.Wait(2);

                var username = driver.FindElement(By.Id("email"));
                var password = driver.FindElement(By.Id("pass"));

                username.Clear();
                username.Clear();

                driver.TypeIntoField(username, credentials.Username);
                driver.Wait(1);

                driver.TypeIntoField(password, credentials.Password + Keys.Enter);
                driver.Wait(2);

                ScenarioEventSourceProvider.EventLog.AccountLogInStop("Facebook");
                Logger.LogWriteLine("    Completed logging into Facebook...");
            }
            else
            {
                Logger.LogWriteLine("    Already logged into Facebook...");
            }

            // Check to makes sure the login was successful
            if (driver.Title == "Log into Facebook | Facebook" || driver.Title == "Facebook - Log In or Sign Up")
            {
                throw new Exception("Login to Facebook failed!");
            }

            // It sometimes takes Facebook several seconds before it pops up a notification popup asking the user to enable or disable facebook notifications.
            // Using 20 seconds to be safe and account for having longer delays on slower devices.
            driver.Wait(20);

            // find the "Turn on Facebook Notifications" window if it exists.
            // This should only show up on the first login to Facebook on a new machine or if cookies have been cleared.
            try
            {
                Logger.LogWriteLine("    Check for Facebook notification request window.");
                notificationWindow = driver.FindElementById("notification-permission-title");

                Logger.LogWriteLine("    Facebook notification request window found! Attempting to click 'Not Now' button.");
                cancelButton = driver.FindElementByLinkText("Not Now");
                driver.ClickElement(cancelButton);

                try
                {
                    // Check again for the notification window. It should be gone at this point.
                    notificationWindow = driver.FindElementById("notification-permission-title");

                    // If we get here then the notification window is still open!
                    throw new Exception("Failed to close Facebook notification window!");
                }
                catch (NoSuchElementException)
                {
                    Logger.LogWriteLine("    Successfully closed the Facebook notification window.");
                }
            }
            catch (NoSuchElementException)
            {
                // No facebook notification window found so continue on our merry way.
                if (notificationWindow == null)
                {
                    Logger.LogWriteLine("    No notification window found. Continuing on with scenario execution.");
                }
                else
                {
                    Logger.LogWriteLine("    Unable to click 'Not Now' button in the Facebook notification request window!");
                    throw;
                }
            }

            // Once we're logged in, all we're going to do is scroll through the page
            // We're simply measuring a user looking through their news feed for a minute
            driver.Wait(1);
            Logger.LogWriteLine("    Scroll through Facebook timeline.");
            ScenarioEventSourceProvider.EventLog.ScenarioActionStart("Scroll through timeline");
            driver.ScrollPage(10);
            ScenarioEventSourceProvider.EventLog.ScenarioActionStop("Scroll through timeline");
        }