Advertisement
Guest User

Untitled

a guest
Jun 17th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.VisualStudio.TestTools.UnitTesting;
  4. using OpenQA.Selenium;
  5. using OpenQA.Selenium.Chrome;
  6. using OpenQA.Selenium.Support.UI;
  7. using System.Linq;
  8.  
  9.  
  10. namespace Register_account
  11. {
  12. [TestClass]
  13. public class UnitTest1
  14. {
  15. [TestMethod]
  16. public void Login()
  17. {
  18. IWebDriver driver = new ChromeDriver();
  19. driver.Url = "http://demoqa.com/registration/";
  20. IWebElement firstName = driver.FindElement(By.Id("name_3_firstname"));
  21.  
  22. firstName.SendKeys("Dilyana");
  23. IWebElement matrialStatus = driver.FindElement(By.XPath("//*[@id=\"pie_register\"]/li[2]/div/div/input[1]"));
  24. matrialStatus.Click();
  25. List<IWebElement> hobbys = driver.FindElements(By.Name("checkbox_5[]")).ToList();
  26. hobbys[0].Click();
  27. hobbys[1].Click();
  28. IWebElement countryDropDown = driver.FindElement(By.Id("dropdown_7"));
  29. SelectElement country = new SelectElement(countryDropDown);
  30. country.SelectByText("Bulgaria");
  31. IWebElement monthDropDown = driver.FindElement(By.Id("mm_date_8"));
  32. SelectElement month = new SelectElement(monthDropDown);
  33. month.SelectByText("1");
  34. IWebElement dayDropdown = driver.FindElement(By.Id("dd_date_8"));
  35. SelectElement day = new SelectElement(dayDropdown);
  36. day.SelectByText("1");
  37. IWebElement yearDropDown = driver.FindElement(By.Id("yy_date_8"));
  38. SelectElement year = new SelectElement(yearDropDown);
  39. year.SelectByText("2014");
  40. IWebElement phone = driver.FindElement(By.Id("phone_9"));
  41. phone.SendKeys("359886625966");
  42. IWebElement username = driver.FindElement(By.Id("username"));
  43. username.SendKeys("DidiBidi");
  44. IWebElement email = driver.FindElement(By.Id("email_1"));
  45. email.SendKeys("dilianavn@gmail.com");
  46. IWebElement picButton = driver.FindElement(By.Id("profile_pic_10"));
  47. picButton.Click();
  48. driver.SwitchTo().ActiveElement().SendKeys(@"C:\Users\Doreto\Downloads\15861603283_3579db3fc6_o.jpg") ;
  49.  
  50.  
  51.  
  52. IWebElement about = driver.FindElement(By.Id("description"));
  53. about.SendKeys("My name is Dilyana and I want to be an amazing QA Engineer");
  54. IWebElement password = driver.FindElement(By.Id("password_2"));
  55. password.SendKeys("D_@123456789101112d");
  56. IWebElement confirmPassword = driver.FindElement(By.Id("confirm_password_password_2"));
  57. confirmPassword.SendKeys("D_@123456789101112d");
  58. IWebElement sentButton = driver.FindElement(By.Name("pie_submit"));
  59. sentButton.Submit();
  60. IWebElement registrationMessage = driver.FindElement(By.ClassName("piereg_message"));
  61. Assert.IsTrue(sentButton.Displayed);
  62. Assert.AreEqual("Thank you for your registration", registrationMessage.Text);
  63. driver.Quit();
  64.  
  65.  
  66.  
  67. }
  68. public void Type(IWebElement element, string text)
  69.  
  70. {
  71.  
  72. element.Clear();
  73.  
  74. element.SendKeys(text);
  75.  
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement