daily pastebin goal
16%
SHARE
TWEET

QACen

a guest Mar 17th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using OpenQA.Selenium.Chrome;
  4. using OpenQA.Selenium.Support.UI;
  5.  
  6.  
  7. namespace QACentric
  8. {
  9.     [TestClass]
  10.     public class UnitTest1
  11.     {
  12.         private ChromeDriver browser;
  13.  
  14.  
  15.         [TestInitialize]
  16.         public void initializeTest()
  17.         {
  18.             browser = new ChromeDriver();
  19.             var page = "http://demoqa.com/registration/";
  20.  
  21.             browser.Manage().Window.Maximize();
  22.             browser.Navigate().GoToUrl(page);
  23.             }
  24.  
  25.  
  26.         [TestCleanup]
  27.         public void CleanUpTest()
  28.         {
  29.             //browser.Close();
  30.  
  31.         }
  32.  
  33.        
  34.  
  35.  
  36.         [TestMethod]
  37.         public void TestMethod1()
  38.         {
  39.            
  40.             var firstName = browser.FindElementById("name_3_firstname");
  41.             firstName.SendKeys("Georgiana");
  42.             firstName.Clear();
  43.  
  44.             var lastName = browser.FindElementById("name_3_lastname");
  45.             lastName.SendKeys("Alexii");
  46.  
  47.            
  48.             var validationMessage = browser.FindElementByXPath("//*[@id='pie_register']/li[1]/div[1]/div[2]/span");
  49.             Assert.AreEqual("* This field is required", validationMessage.Text);
  50.  
  51.         }
  52.  
  53.  
  54.         [TestMethod]
  55.         public void TestMethod2()
  56.  
  57.         {
  58.             var firstName = browser.FindElementById("name_3_firstname");
  59.             firstName.SendKeys("Georgiana");
  60.            
  61.  
  62.             var lastName = browser.FindElementById("name_3_lastname");
  63.             lastName.SendKeys("Alexii");
  64.  
  65.  
  66.             var status = browser.FindElementByXPath("//*[@id=\"pie_register\"]/li[2]/div/div/input[1]");
  67.             status.Click();
  68.  
  69.             //Hobbies
  70.  
  71.             var hobbyDancing =
  72.                 browser.FindElementByCssSelector("#pie_register > li:nth-child(3) > div > div > input:nth-child(2)");
  73.  
  74.             var hobbyReading =
  75.                 browser.FindElementByCssSelector("#pie_register > li:nth-child(3) > div > div > input:nth-child(4)");
  76.  
  77.             hobbyDancing.Click();
  78.             hobbyReading.Click();
  79.  
  80.  
  81.  
  82.  
  83.             //Tara
  84.             var country = "Romania";
  85.             var selectCountry = browser.FindElementByXPath("//*[@id='dropdown_7']/option[@value='" + country + "']");
  86.             selectCountry.Click();
  87.  
  88.  
  89.  
  90.             //BirthDate
  91.             var monthValue = "7";
  92.             var dayValue = "28";
  93.             var yearValue = "1995";
  94.  
  95.             var month = browser.FindElementById("mm_date_8");
  96.             var day = browser.FindElementById("dd_date_8");
  97.             var year = browser.FindElementById("yy_date_8");
  98.  
  99.             month.SendKeys(monthValue);
  100.             day.SendKeys(dayValue);
  101.             year.SendKeys(yearValue);
  102.  
  103.  
  104.  
  105.             //Phone
  106.  
  107.             var phone = browser.FindElementById("phone_9");
  108.             phone.SendKeys("0754678511");
  109.             //Username
  110.             var username = browser.FindElementById("username");
  111.             username.SendKeys("MissAsmodvvjjdeus");
  112.             //Email
  113.             var email = browser.FindElementById("email_1");
  114.  
  115.  
  116.             email.SendKeys("georgiana.aledoodxii@yahoo.com");
  117.  
  118.  
  119.             //Profile Pic
  120.             var profilePic = browser.FindElementById("profile_pic_10");
  121.             profilePic.SendKeys("C:\\Program Files (x86)\\Google\\Chrome\\Application\\64.0.3282.186\\eye.jpg");
  122.            
  123.  
  124.             //AboutYourself
  125.             var aboutYou = browser.FindElementById("description");
  126.             aboutYou.SendKeys("Ceva despre mine!!!!!!!!!^_^");
  127.  
  128.  
  129.  
  130.             //Password
  131.             var password = browser.FindElementById("password_2");
  132.             password.SendKeys("3359xa78x@@aaaaaaaaaa");
  133.  
  134.             //Password confirm
  135.             var confirmPassword = browser.FindElementById("confirm_password_password_2");
  136.             confirmPassword.SendKeys("3359xa78x@@aaaaaaaaaa");
  137.  
  138.  
  139.             //Submit button
  140.             var submitButton = browser.FindElementByXPath("//*[@id='pie_register']/li[14]/div/input");
  141.             submitButton.Click();
  142.  
  143.         }
  144.  
  145.     }
  146. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top