Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- using OpenQA.Selenium.Support.UI;
- using System.Collections.Generic;
- using System.Linq;
- namespace Register_account
- {
- [TestClass]
- public class UnitTest1
- {
- IWebDriver driver = new ChromeDriver();
- [TestMethod]
- public void Login()
- {
- ChromeOptions options = new ChromeOptions();
- options.AddArguments("--start-maximized");
- driver = new ChromeDriver(options);
- driver.Url = "http://demoqa.com/registration/";
- IWebElement firstName = driver.FindElement(By.Id("name_3_firstname"));
- firstName.SendKeys("Dilyana");
- IWebElement secondName = driver.FindElement(By.Id("name_3_lastname"));
- secondName.SendKeys("Nikolaeva");
- IWebElement matrialStatus = driver.FindElement(By.XPath("//*[@id=\"pie_register\"]/li[2]/div/div/input[1]"));
- matrialStatus.Click();
- List<IWebElement> hobbys = driver.FindElements(By.Name("checkbox_5[]")).ToList();
- hobbys[0].Click();
- hobbys[1].Click();
- IWebElement countryDropDown = driver.FindElement(By.Id("dropdown_7"));
- SelectElement country = new SelectElement(countryDropDown);
- country.SelectByText("Bulgaria");
- IWebElement monthDropDown = driver.FindElement(By.Id("mm_date_8"));
- SelectElement month = new SelectElement(monthDropDown);
- month.SelectByText("1");
- IWebElement dayDropdown = driver.FindElement(By.Id("dd_date_8"));
- SelectElement day = new SelectElement(dayDropdown);
- day.SelectByText("1");
- IWebElement yearDropDown = driver.FindElement(By.Id("yy_date_8"));
- SelectElement year = new SelectElement(yearDropDown);
- year.SelectByText("2014");
- IWebElement phone = driver.FindElement(By.Id("phone_9"));
- phone.SendKeys("359886625966");
- IWebElement username = driver.FindElement(By.Id("username"));
- username.SendKeys("DidiBidi");
- IWebElement email = driver.FindElement(By.Id("email_1"));
- email.SendKeys("dilianavn@gmail.com");
- driver.FindElement(By.Id("profile_pic_10")).SendKeys(@"C:\Users\Doreto\Downloads\15861603283_3579db3fc6_o.jpg");
- IWebElement about = driver.FindElement(By.Id("description"));
- about.SendKeys("My name is Dilyana and I want to be an amazing QA Engineer");
- IWebElement password = driver.FindElement(By.Id("password_2"));
- password.SendKeys("D_@123456789101112d");
- IWebElement confirmPassword = driver.FindElement(By.Id("confirm_password_password_2"));
- confirmPassword.SendKeys("D_@123456789101112d");
- IWebElement sentButton = driver.FindElement(By.Name("pie_submit"));
- sentButton.Click();
- IWebElement registrationMessage = driver.FindElement(By.CssSelector("#post-49 > div > p"));
- // Assert.IsTrue(sentButton.Displayed); Този ред не беше закоментиран и трошеше всичко, ама яко
- if (registrationMessage.Text == "Thank you for your registration")
- {
- //Преправих тотално този ред
- Assert.AreEqual("Thank you for your registration", registrationMessage.Text);
- }
- else
- {
- //Преправих тотално и този ред
- Assert.AreEqual("Error: Username already exists", registrationMessage.Text);
- }
- driver.Quit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement