Notes
Notes - notes.io |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Support.UI;
using NUnit.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;
namespace PageObjectModel
{
[TestClass]
public static class ControlProperties
{
public static By clickCookies = By.Id("pgdg-continue");
public static By signupClick = By.XPath("//*[@id='ctl00_ContentMain_HyperlinkRegister']");
//public static By email = By.Name("ctl00$ContentMain$TextBoxEmail");
public static By firstName = By.Name("ctl00$ContentMain$TextBoxFirstName");
public static By lastName = By.Name("ctl00$ContentMain$TextBoxLastName");
public static By password = By.XPath("//*[@id='ctl00_ContentMain_TextBoxPassword']");
public static By confirmPassword = By.Name("ctl00$ContentMain$TextBoxPasswordConfirm");
public static By countryDropdown = By.Name("ctl00$ContentMain$DropdownListCountry");
public static By email = By.Name("ctl00$ContentMain$TextBoxEmail");
public static By zipCode = By.XPath("//*[@id='TextBoxZip']");
public static By city = By.XPath("//*[@id='TextBoxCity']");
public static By city2 = By.XPath("//*[@id='TextBoxCity']");
public static By securityAnswer = By.Id("ctl00_ContentMain_TextBoxAnswer");
}
[TestClass]
public class PageObjectModelMethods
{
IWebDriver webDriver;
public void ClickCookies()
{
webDriver.FindElement(ControlProperties.clickCookies).Click();
WaitTime();
}
public void SignUpClick()
{
webDriver.FindElement(ControlProperties.signupClick).Click();
WaitTime();
}
public PageObjectModelMethods(IWebDriver driver)
{
this.webDriver = driver;
}
public void LastName(string userLastName)
{
webDriver.FindElement(ControlProperties.lastName).Clear();
webDriver.FindElement(ControlProperties.lastName).SendKeys(userLastName);
WaitTime();
}
public void Password(string userPassword)
{
webDriver.FindElement(ControlProperties.password).Clear();
webDriver.FindElement(ControlProperties.password).SendKeys(userPassword);
WaitTime();
}
public void ConfirmPassword(string userConfirmPassword)
{
webDriver.FindElement(ControlProperties.confirmPassword).Clear();
webDriver.FindElement(ControlProperties.confirmPassword).SendKeys(userConfirmPassword);
WaitTime();
}
public void CountryDopDown(string countryName)
{
//Thread.Sleep(3000);
IWebElement countryDrop = webDriver.FindElement(ControlProperties.countryDropdown);
countryDrop.Click();
SelectElement select = new SelectElement(countryDrop);
select.SelectByValue(countryName);
WaitTime();
}
public void ZipCode(string userZipCode)
{
webDriver.FindElement(ControlProperties.zipCode).Clear();
webDriver.FindElement(ControlProperties.zipCode).SendKeys(userZipCode);
WaitTime();
}
public void City(string userCity)
{
//Thread.Sleep(3000);
//webDriver.FindElement(ControlProperties.city).Clear();
webDriver.FindElement(ControlProperties.city).SendKeys(userCity);
//Thread.Sleep(1000);
WaitTime();
}
public void City2(string userCity2)
{
//webDriver.FindElement(ControlProperties.city).Clear();
webDriver.FindElement(ControlProperties.city2).SendKeys(userCity2);
WaitTime();
}
public void SecurityAnswer(string userSecurityAnswer)
{
webDriver.FindElement(ControlProperties.securityAnswer).Clear();
webDriver.FindElement(ControlProperties.securityAnswer).SendKeys(userSecurityAnswer);
WaitTime();
}
public void EnterEmail(string userEmail)
{
Thread.Sleep(2000);
webDriver.FindElement(ControlProperties.email).Clear();
webDriver.FindElement(ControlProperties.email).SendKeys(userEmail);
WaitTime();
}
public void FirstName(string userFirstName)
{
webDriver.FindElement(ControlProperties.firstName).Clear();
webDriver.FindElement(ControlProperties.firstName).SendKeys(userFirstName);
WaitTime();
}
public void WaitTime()
{
WebDriverWait webDriverWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));
}
}
[TestClass]
public class DriverInitialization
{
IWebDriver Webdriver;
public DriverInitialization()
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("disable-infobars");
Webdriver = new ChromeDriver(@"D:chromedriver_win32", chromeOptions);
Webdriver.Navigate().GoToUrl("https://www.c-sharpcorner.com/login?returnurl=/article/c-sharp-corner-signup-page-with-page-object-model-design-pattern-in-selenium/");
Thread.Sleep(3000);
Webdriver.Manage().Window.Maximize();
WebDriverWait webDriverWait = new WebDriverWait(Webdriver, TimeSpan.FromSeconds(40));
}
[TestMethod]
public void UserRegisteration()
{
// Four User Login Data.
PageObjectModelMethods register = new PageObjectModelMethods(Webdriver);
register.ClickCookies();
register.SignUpClick();
register.EnterEmail("[email protected]");
register.FirstName("Khaja");
register.LastName("Moizuddin");
register.Password("1234567890");
register.ConfirmPassword("1234567890");
register.CountryDopDown("India");
register.ZipCode("500076");
register.City("L");
register.City2("LONDON");
register.SecurityAnswer("Valuemomentum Software Services");
//Webdriver.Quit();
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team