Exemple #1
0
        public void RegistrationEmptyNameField()
        {
            driver.Url = "http://demoqa.com/registration/";

            //IWebElement firstName = driver.FindElement(By.Id("name_3_firstname"));
            // Type(firstName, "Toni");
            // IWebElement lastName = driver.FindElement(By.Id("name_3_lastname"));
            // Type(lastName, "Naika");
            IWebElement maritalStatus = driver.FindElement(By.XPath("//*[@id=\"pie_register\"]/li[2]/div/div/input[1]"));

            maritalStatus.Click();
            List <IWebElement> hobbys = driver.FindElements(By.Name("checkbox_5[]")).ToList();

            hobbys[0].Click();
            hobbys[2].Click();
            IWebElement   countryDropDown = driver.FindElement(By.Id("dropdown_7"));
            SelectElement countryOption   = new SelectElement(countryDropDown);

            countryOption.SelectByText("Bulgaria");
            IWebElement   mountDropDown = driver.FindElement(By.Id("mm_date_8"));
            SelectElement mountOption   = new SelectElement(mountDropDown);

            mountOption.SelectByValue("3");
            IWebElement   dayDropDown = driver.FindElement(By.Id("dd_date_8"));
            SelectElement dayOption   = new SelectElement(dayDropDown);

            dayOption.SelectByText("3");
            IWebElement   yearDropDown = driver.FindElement(By.Id("yy_date_8"));
            SelectElement yearOption   = new SelectElement(yearDropDown);

            yearOption.SelectByValue("1989");
            IWebElement telephone = driver.FindElement(By.Id("phone_9"));

            Type(telephone, "359999999999");
            IWebElement userName = driver.FindElement(By.Id("username"));

            Type(userName, "ToniNaika");
            IWebElement email = driver.FindElement(By.Id("email_1"));

            Type(email, "*****@*****.**");
            IWebElement uploadPicButton = driver.FindElement(By.Id("profile_pic_10"));

            uploadPicButton.Click();
            driver.SwitchTo().ActiveElement().SendKeys(@"C:\Users\hrist\Desktop\Ceca.jpg");
            IWebElement description = driver.FindElement(By.Id("description"));

            Type(description, "Ceca Forever!");
            IWebElement password = driver.FindElement(By.Id("password_2"));

            Type(password, "123456789");
            IWebElement confirmPassword = driver.FindElement(By.Id("confirm_password_password_2"));

            Type(confirmPassword, "123456789");
            IWebElement submitButton = driver.FindElement(By.Name("pie_submit"));

            submitButton.Click();

            IWebElement errorMessage = driver.FindElement(By.XPath("//*[@id='pie_register']/li[1]/div[1]/div[2]/span"));

            Assert.AreEqual("* This field is required", errorMessage.Text);
        }