コード例 #1
0
        public void WrongChar()
        {
            //For Mac Inıtialize the Safari Driver
            SafariDriver safariDriver = new SafariDriver();

            // Maximize the browser
            safariDriver.Manage().Window.Maximize();

            // Go to the "Lolaflora" login page
            safariDriver.Navigate().GoToUrl("https://www.lolaflora.com/en-es/login");

            // Find the email/username textbox (by ID) on the login page
            var emailBox = safariDriver.FindElementById("EmailLogin");

            String [] wrongChar = { "!", ":", "?", ";", ",", "'", "%", "&", "/", "<", ">", "(", ")", "[", "]", "{", "}", "*" };

            Random random = new Random();
            int    rand   = random.Next(0, wrongChar.Length - 1);

            // Enter the mail adress for login
            emailBox.SendKeys("*****@*****.**" + wrongChar[rand]);

            // Find the password (by ID) on the login page
            var passwordBox = safariDriver.FindElementById("Password");

            // Enter the password for login
            passwordBox.SendKeys("123456789");

            // Find the search button (by Name) on the homepage
            var signIn = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[6]/button");

            // Click "Submit" to start the search
            signIn.SendKeys(Keys.Return);

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //Find an element on page after login
            var failLoginRemark = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[2]/span[1]");

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //[email protected]
            //123654789

            safariDriver.Dispose();
        }
コード例 #2
0
        public void WithoutAtCharOnMailAddress()
        {
            //For Mac Inıtialize the Safari Driver
            SafariDriver safariDriver = new SafariDriver();

            // Maximize the browser
            safariDriver.Manage().Window.Maximize();

            // Go to the "Lolaflora" login page
            safariDriver.Navigate().GoToUrl("https://www.lolaflora.com/en-es/login");

            // Find the email/username textbox (by ID) on the login page
            var emailBox = safariDriver.FindElementById("EmailLogin");

            // Enter the mail adress for login
            emailBox.SendKeys("testusertestuser.com");

            // Find the password (by ID) on the login page
            var passwordBox = safariDriver.FindElementById("Password");

            // Enter the password for login
            passwordBox.SendKeys("123654789");

            // Find the search button (by Name) on the homepage
            var signIn = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[6]/button");

            // Click "Submit" to start the search
            signIn.SendKeys(Keys.Return);

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //Find an element on page after login
            var failLoginRemark = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[2]/span[1]");

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //[email protected]
            //123654789


            safariDriver.Dispose();
        }
コード例 #3
0
 public void QuitDriver()
 {
     safari.Quit();
     safari.Dispose();
 }