Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using OpenQA.Selenium;
- using TestingProject.TestBase;
- using OpenQA.Selenium.Support.UI;
- using OpenQA.Selenium.IE;
- using TestingProject.TestConstant;
- namespace TestingProject
- {
- //first class. the base class where the driver class is inherited
- public class Layers : TestBase.TestBase
- {
- public Layers() { }
- public Layers(IWebDriver driver) : base(driver){ }
- public void LayerOne(String ExpectedElement)
- {
- driver.FindElement(By.CssSelector(ExpectedElement)).Click();
- }
- }
- //second class. This contains a method that passes parameter to force the driver to wait until the expected element is visible
- public class Layers2Class : TestBase.TestBase
- {
- public Layers2Class() { }
- public Layers2Class(IWebDriver driver) : base(driver) { }
- public void FullElementPageLoad(String WaitPeriodParameter)
- {
- WebDriverWait tests = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
- tests.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(WaitPeriodParameter)));
- }
- }
- //combined class. This class has a method that passes parameters into the first 2 classes instantiated within it.
- public class LayerCombined : TestBase.TestBase
- {
- public LayerCombined() { }
- public LayerCombined(IWebDriver driver) : base(driver) { }
- public void FullElementPageLoad(String WaitPeriod, String elementpresent)
- {
- new Layers2Class(driver).FullElementPageLoad(WaitPeriod);
- new Layers(driver).LayerOne(elementpresent);
- }
- }
- //This is class in which the actual expected parameters are passed into the first 2 classes.
- public class LayerParam : TestBase.TestBase
- {
- public LayerParam() { }
- public LayerParam(IWebDriver driver) : base(driver) { }
- public void CollectParam()
- {
- LayerCombined LayerCombined = new LayerCombined(driver);
- LayerCombined.FullElementPageLoad("#content > div > div.col-xs-12.col-sm-12.col-md-7.col-lg-8.hidden-xs.hidden-sm > div.hero > img", "#btnSigin");
- }
- }
- //It is in this class in which the test is ran.
- [TestClass]
- public class ClassRunner : TestBase.TestBase
- {
- public ClassRunner() { }
- public ClassRunner(IWebDriver driver) : base(driver) { }
- [TestMethod]
- public void RunAll()
- {
- driver = new InternetExplorerDriver();
- driver.Navigate().GoToUrl("http://www.google.com");
- new LayerParam(driver).CollectParam();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement