Advertisement
Guest User

Test Passed

a guest
Jun 26th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.77 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using OpenQA.Selenium;
  3. using OpenQA.Selenium.Chrome;
  4. using OpenQA.Selenium.Support.UI;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7.  
  8.  
  9. namespace Register_account
  10. {
  11.     [TestClass]
  12.     public class UnitTest1
  13.     {
  14.         IWebDriver driver = new ChromeDriver();
  15.  
  16.         [TestMethod]
  17.         public void Login()
  18.         {
  19.             ChromeOptions options = new ChromeOptions();
  20.             options.AddArguments("--start-maximized");
  21.             driver = new ChromeDriver(options);
  22.  
  23.             driver.Url = "http://demoqa.com/registration/";
  24.             IWebElement firstName = driver.FindElement(By.Id("name_3_firstname"));
  25.             firstName.SendKeys("Dilyana");
  26.  
  27.             IWebElement secondName = driver.FindElement(By.Id("name_3_lastname"));
  28.             secondName.SendKeys("Nikolaeva");
  29.  
  30.             IWebElement matrialStatus = driver.FindElement(By.XPath("//*[@id=\"pie_register\"]/li[2]/div/div/input[1]"));
  31.             matrialStatus.Click();
  32.  
  33.             List<IWebElement> hobbys = driver.FindElements(By.Name("checkbox_5[]")).ToList();
  34.             hobbys[0].Click();
  35.             hobbys[1].Click();
  36.  
  37.             IWebElement countryDropDown = driver.FindElement(By.Id("dropdown_7"));
  38.             SelectElement country = new SelectElement(countryDropDown);
  39.             country.SelectByText("Bulgaria");
  40.  
  41.             IWebElement monthDropDown = driver.FindElement(By.Id("mm_date_8"));
  42.             SelectElement month = new SelectElement(monthDropDown);
  43.             month.SelectByText("1");
  44.  
  45.             IWebElement dayDropdown = driver.FindElement(By.Id("dd_date_8"));
  46.             SelectElement day = new SelectElement(dayDropdown);
  47.             day.SelectByText("1");
  48.  
  49.             IWebElement yearDropDown = driver.FindElement(By.Id("yy_date_8"));
  50.             SelectElement year = new SelectElement(yearDropDown);
  51.             year.SelectByText("2014");
  52.  
  53.             IWebElement phone = driver.FindElement(By.Id("phone_9"));
  54.             phone.SendKeys("359886625966");
  55.  
  56.             IWebElement username = driver.FindElement(By.Id("username"));
  57.             username.SendKeys("DidiBidi");
  58.  
  59.             IWebElement email = driver.FindElement(By.Id("email_1"));
  60.             email.SendKeys("dilianavn@gmail.com");
  61.  
  62.             driver.FindElement(By.Id("profile_pic_10")).SendKeys(@"C:\Users\Doreto\Downloads\15861603283_3579db3fc6_o.jpg");
  63.  
  64.             IWebElement about = driver.FindElement(By.Id("description"));
  65.             about.SendKeys("My name is Dilyana and I want to be an amazing QA Engineer");
  66.  
  67.             IWebElement password = driver.FindElement(By.Id("password_2"));
  68.             password.SendKeys("D_@123456789101112d");
  69.             IWebElement confirmPassword = driver.FindElement(By.Id("confirm_password_password_2"));
  70.             confirmPassword.SendKeys("D_@123456789101112d");
  71.  
  72.             IWebElement sentButton = driver.FindElement(By.Name("pie_submit"));
  73.             sentButton.Click();
  74.  
  75.             IWebElement registrationMessage = driver.FindElement(By.CssSelector("#post-49 > div > p"));
  76.  
  77.  
  78.  
  79.  
  80.            // Assert.IsTrue(sentButton.Displayed);  Този ред не беше закоментиран и трошеше всичко, ама яко
  81.  
  82.             if (registrationMessage.Text == "Thank you for your registration")
  83.             {
  84.                 //Преправих тотално този ред
  85.                 Assert.AreEqual("Thank you for your registration", registrationMessage.Text);
  86.             }
  87.             else
  88.             {
  89.                 //Преправих тотално и този ред
  90.                 Assert.AreEqual("Error: Username already exists", registrationMessage.Text);
  91.             }
  92.  
  93.             driver.Quit();
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement