Skip to content

Commit

Permalink
Building BedroomUnpossesed Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmmay committed May 30, 2022
1 parent adb7b75 commit fb1c606
Show file tree
Hide file tree
Showing 26 changed files with 272 additions and 64 deletions.
Binary file modified ConjuringTests/.vs/ConjuringTests/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ConjuringTests/.vs/ConjuringTests/v17/.suo
Binary file not shown.
Binary file modified ConjuringTests/.vs/ProjectEvaluation/conjuringtests.metadata.v2
Binary file not shown.
Binary file modified ConjuringTests/.vs/ProjectEvaluation/conjuringtests.projects.v2
Binary file not shown.
35 changes: 2 additions & 33 deletions ConjuringTests/BasementPageObject.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConjuringTests.Drivers;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;

namespace ConjuringTests.Pages
{
public class BasementPageObject
{
private const string BasementUrl = "https://ethanmmay.github.io/conjuring-site/basement-b";

private readonly IWebDriver _webDriver;

public const int DefaultWaitInSeconds = 5;
Expand All @@ -25,14 +16,6 @@ public BasementPageObject(IWebDriver webDriver)

private IWebElement PianoImage => _webDriver.FindElement(By.ClassName("pianoImage"));

public void VerifyAtBasementPage()
{
if (_webDriver.Url != BasementUrl)
{
_webDriver.Url = BasementUrl;
}
}

public void ScrollDown()
{
var piano = _webDriver.FindElement(By.ClassName("pianoImage"));
Expand All @@ -48,23 +31,9 @@ public void ClickPiano()

public void VerifyPianoAlertAppears()
{
Thread.Sleep(5000);
Thread.Sleep(3000);
_webDriver.SwitchTo().Alert().Accept();
}

private T WaitUntil<T>(Func<T> getResult, Func<T, bool> isResultAccepted) where T : class
{
var wait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(DefaultWaitInSeconds));
#pragma warning disable CS8603 // Possible null reference return.
return wait.Until(driver =>
{
var result = getResult();
if (!isResultAccepted(result))
return default;

return result;
});
#pragma warning restore CS8603 // Possible null reference return.
Thread.Sleep(2000);
}
}
}
Empty file.
51 changes: 51 additions & 0 deletions ConjuringTests/BedroomGPageObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConjuringTests.Drivers;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;

namespace ConjuringTests.Pages
{
public class BedroomGPageObject
{
private readonly IWebDriver _webDriver;

public const int DefaultWaitInSeconds = 5;

public BedroomGPageObject(IWebDriver webDriver)
{
_webDriver = webDriver;
}

private IWebElement wardrobe => _webDriver.FindElement(By.ClassName("wardrobeImage"));
private IWebElement weightInput => _webDriver.FindElement(By.Id("weightFormInput"));
private IWebElement submitButton => _webDriver.FindElement(By.Id("weightFormButton"));
//private IWebElement

public void ClickWardrobeAndAlert()
{
wardrobe.Click();
_webDriver.SwitchTo().Alert().Accept();
}

public void EnterWeightAndSubmit(int weight)
{
weightInput.Clear();
weightInput.SendKeys(weight.ToString());
submitButton.Click();
}

public void RepeatStepsAndEnterHighWeight(int weight)
{

}




}
}
4 changes: 2 additions & 2 deletions ConjuringTests/Features/BasementPossession.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions ConjuringTests/Features/BedroomUnpossessed.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: BedroomUnpossessed

Go to Bedroom while unpossessed, click wardrobe, accept alert, enter weight, repeat

@testBedroomG
Scenario: Test Bedroom while Unpossessed
Given I am on conjuring site going towards BedroomG
When I click BedroomG
When I click on wardrobe and alert
When I enter low weight and submit
When I repeat steps and enter high weight
Then I fall through the house
144 changes: 144 additions & 0 deletions ConjuringTests/Features/BedroomUnpossessed.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 6 additions & 27 deletions ConjuringTests/HomePageObject.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConjuringTests.Drivers;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium;

namespace ConjuringTests.Pages
{
public class HomePageObject
{
private const string HomePageUrl = "https://ethanmmay.github.io/conjuring-site";
private const string BasementUrl = "https://ethanmmay.github.io/conjuring-site/basement-b";

private readonly IWebDriver _webDriver;

Expand All @@ -23,10 +15,10 @@ public HomePageObject(IWebDriver webDriver)
_webDriver = webDriver;
}

private string CurrentLocation => _webDriver.Url;
private IWebElement PossessionButton => _webDriver.FindElement(By.ClassName("possessButton"));
private IWebElement BasementLink => _webDriver.FindElement(By.LinkText("Basement"));
private IWebElement OutsideLink => _webDriver.FindElement(By.LinkText("Outside"));
private IWebElement BedroomLink => _webDriver.FindElement(By.LinkText("Bedroom"));

public void VerifyAtHomePage()
{
Expand All @@ -51,27 +43,14 @@ public void NavigateToOutside()
OutsideLink.Click();
}

public void VerifyAtBasement()
public void NavigateToBedroomG()
{
if (_webDriver.Url != BasementUrl)
{
_webDriver.Url = BasementUrl;
}
BedroomLink.Click();
}

private T WaitUntil<T>(Func<T> getResult, Func<T, bool> isResultAccepted) where T : class
public void NavigateToBedroomB()
{
var wait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(DefaultWaitInSeconds));
#pragma warning disable CS8603 // Possible null reference return.
return wait.Until(driver =>
{
var result = getResult();
if (!isResultAccepted(result))
return default;

return result;
});
#pragma warning restore CS8603 // Possible null reference return.
BedroomLink.Click();
}
}
}
Empty file.
Loading

0 comments on commit fb1c606

Please sign in to comment.