gabi11

Selenium Basic - Registration Tests

May 19th, 2020
1,782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using NUnit.Framework;
  2. using OpenQA.Selenium;
  3. using OpenQA.Selenium.Chrome;
  4. using OpenQA.Selenium.Support.UI;
  5. using System;
  6. using System.IO;
  7. using System.Reflection;
  8.  
  9. namespace SeleniumBasic
  10. {
  11.     [TestFixture]
  12.     class RegistrationTests
  13.     {
  14.         private IWebDriver _driver;
  15.         private WebDriverWait _wait;
  16.  
  17.         [SetUp]
  18.         public void SetUp()
  19.         {
  20.             _driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
  21.             _driver.Url = "http://automationpractice.com/index.php";
  22.  
  23.             _wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(2));
  24.         }
  25.  
  26.         [TearDown]
  27.         public void TearDown()
  28.         {
  29.             _driver.Quit();
  30.         }
  31.  
  32.         [Test]
  33.         public void OpenTheNavigationBar()
  34.         {
  35.             IWebElement signInButton = _driver.FindElement(By.XPath("/html/body/div/div[1]/header/div[2]/div/div/nav/div[1]/a"));
  36.             signInButton.Click();
  37.  
  38.             IWebElement createSection =
  39.                 _wait.Until<IWebElement>(c => c.FindElement(By.CssSelector("#email_create")));
  40.             createSection.SendKeys("[email protected]");
  41.             createSection.SendKeys(Keys.Enter);
  42.  
  43.             IWebElement emailInformationField =
  44.                 _wait.Until<IWebElement>(e => e.FindElement(By.XPath("html/body/div/div[2]/div/div[3]/div/div/form/div[1]/div[4]/input")));
  45.  
  46.             var expectedMail = "[email protected]";
  47.  
  48.             Assert.AreEqual(expectedMail, emailInformationField.GetAttribute("value"));
  49.  
  50.         }
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment