public void WhenISelectTheVectorsButton(int vector) { SeleniumPage.Should().BeFound() .Then().RadioButton(vector) .Should().BeFound() .Then().Click(); }
public void TestGetFillMethodForMultipleSelectControl() { var option = new Mock <IWebElement>(MockBehavior.Strict); option.SetupGet(o => o.Selected).Returns(false); this.SetupClick(option); var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("select"); element.Setup(e => e.GetAttribute("multiple")).Returns("true"); element.Setup(e => e.FindElements(By.TagName("option"))) .Returns(new ReadOnlyCollection <IWebElement>(new[] { option.Object })); element.Setup(e => e.FindElements(By.XPath(".//option[normalize-space(.) = \"Selected Item\"]"))) .Returns(new ReadOnlyCollection <IWebElement>(new[] { option.Object })); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "Selected Item"); element.VerifyAll(); }
public void TestGetElementOptionsForComboBox() { var optionElement = new Mock <IWebElement>(MockBehavior.Strict); optionElement.SetupGet(e => e.Text).Returns("Option 1"); optionElement.Setup(e => e.GetAttribute("value")).Returns("0"); var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("select"); element.Setup(e => e.GetAttribute("multiple")).Returns("false"); element.Setup(e => e.FindElements(By.TagName("option"))) .Returns((new IWebElement[] { optionElement.Object }).ToList().AsReadOnly()); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetElementOptions(element.Object); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); var option = result.First(); Assert.AreEqual("0", option.Value); Assert.AreEqual("Option 1", option.Text); element.VerifyAll(); }
public void ThenTheVectorShouldBeDisplayed(int vector) { SeleniumPage.Should().BeFound() .Then().VectorTable(vector) .Should().BeFound(); var vectorRows = vector switch { 3 => new ThirdVector().VectorRows, 4 => new FourthVector().VectorRows, 5 => new FifthVector().VectorRows, _ => throw new ArgumentOutOfRangeException(nameof(vector), vector, $"{vector} is not a known value") }; if (vectorRows == null) { return; } foreach (var vectorRow in vectorRows) { var vectorBarGraph = SeleniumPage.VectorTable(vector) .Should().BeFound().Then() .VectorBarGraphs.SingleOrDefault(x => x.Title.Text == vectorRow.Title); vectorBarGraph.Should().NotBeNull(); vectorBarGraph.Should().BeFound(); Debug.Assert(vectorBarGraph != null, nameof(vectorBarGraph) + " != null"); var tuples = new List <(SeleniumElement, string, int?)> { (vectorBarGraph.Row627, "6-27", vectorRow.DistanceOf627), (vectorBarGraph.Row630, "6-30", vectorRow.DistanceOf630), (vectorBarGraph.Row6Z13, "6Z13", vectorRow.DistanceOf6Z13), (vectorBarGraph.Row6Z23, "6Z23", vectorRow.DistanceOf6Z23), (vectorBarGraph.Row6Z49, "6Z49", vectorRow.DistanceOf6Z49), (vectorBarGraph.Row6Z50, "6Z50", vectorRow.DistanceOf6Z50) }; foreach (var tuple in tuples) { var(row, expectedText, expectedDistance) = tuple; if (!expectedDistance.HasValue || expectedDistance <= 0) { continue; } row.Text.Should().BeEquivalentTo(expectedText); row.GetAttribute("style") .Should().Contain($"width: {expectedDistance * 25}%"); } vectorBarGraph.DistanceKeys.Rows.Single() .Columns.Select(x => x.Text) .Should().BeEquivalentTo(Enumerable.Range(0, 5) .Select(x => x.ToString(CultureInfo.InvariantCulture))); } } }
public void TestGetNativePage() { var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetNativePage<NativePage>(); Assert.AreSame(nativePage, result); }
public void SetUp() { Initialize(); _googleHomePage = new GoogleHome(Driver); _googleResultsPage = new GoogleSearchResults(Driver); _seleniumPage = new SeleniumPage(Driver); _googleHomePage.NavigateTo(); }
public void TestGetPageType() { var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.PageType; Assert.AreEqual(typeof(NativePage), result); }
public void TestGetNativePage() { var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetNativePage <NativePage>(); Assert.AreSame(nativePage, result); }
public void TestGetPageType() { var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.PageType; Assert.AreEqual(typeof(NativePage), result); }
public SeleniumPage NavigateToSeleniumPage() { LinkFooter.Click(); SeleniumPage seleniumPage = new SeleniumPage(Driver); Driver.SwitchTo().Window(Driver.WindowHandles.Last()); WaitTillSeleniumPageIsLoaded(); return(seleniumPage); }
public void ThenTheSetsTreeShouldBeDisplayed(string sets) { SeleniumPage.TreeElement(sets) .Should().BeFound().Then() .Branches.Should().AllBeFound() .Then().SelectMany(x => x.ChildBranches) .Should().AllBeFound() .Then().SelectMany(x => x.ChildBranches) .Should().AllBeFound(); }
public void TestGetPageFromElement() { var element = new Mock<IWebElement>(MockBehavior.Strict); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetPageFromElement(element.Object); Assert.IsNotNull(result); element.VerifyAll(); }
public void TestGetPageFromElement() { var element = new Mock <IWebElement>(MockBehavior.Strict); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetPageFromElement(element.Object); Assert.IsNotNull(result); element.VerifyAll(); }
public void TestElementExistsCheckWhenDisplayedReturnsTrue() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Returns(true); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.ElementExistsCheck(element.Object); Assert.AreEqual(true, result); element.VerifyAll(); }
public void TestElementEnabledCheckWhenNotDisplayedReturnsFalse() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Returns(false); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.ElementEnabledCheck(element.Object); Assert.AreEqual(false, result); element.VerifyAll(); }
public void TestGetElementOptionsForOtherControl() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("text"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetElementOptions(element.Object); Assert.IsNull(result); element.VerifyAll(); }
public void TestElementEnabledCheckWhenElementNotVisibleExceptionReturnsFalse() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Throws <ElementNotVisibleException>(); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.ElementEnabledCheck(element.Object); Assert.AreEqual(false, result); element.VerifyAll(); }
public void TestGetClickElement() { var element = new Mock <IWebElement>(MockBehavior.Strict); this.SetupClick(element); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.ClickElement(element.Object); Assert.AreEqual(true, result); element.VerifyAll(); }
public void TestElementEnabledCheckWhenStaleElementReferenceReturnsFalse() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Throws <StaleElementReferenceException>(); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.ElementEnabledCheck(element.Object); Assert.IsFalse(result); element.VerifyAll(); }
public void TestGetElementTextWhenControlIsNotSpecialReturnsTheElementText() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("DIV"); element.SetupGet(e => e.Text).Returns("Normal Text"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetElementText(element.Object); Assert.AreEqual("Normal Text", result); element.VerifyAll(); }
public void TestGetClearMethod() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.Setup(e => e.Clear()); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var clearMethod = page.GetClearMethod(null); clearMethod(element.Object); element.VerifyAll(); }
public void TestGetElementAttributeValueWithValidAttribute() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.Setup(e => e.GetAttribute("href")).Returns("http://myurl.com/page"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetElementAttributeValue(element.Object, "href"); Assert.AreEqual("http://myurl.com/page", result); element.VerifyAll(); }
public void TestWaitForControlNotEnabled() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Enabled).Returns(false); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.WaitForElement(element.Object, WaitConditions.NotEnabled, null); Assert.IsTrue(result); element.VerifyAll(); }
public void TestWaitForControlExpectExistButIsNot() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Returns(false); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.WaitForElement(element.Object, WaitConditions.Exists, null); Assert.IsFalse(result); element.VerifyAll(); }
public void TestTryGetCorrectElement() { var element = new Mock<IWebElement>(MockBehavior.Strict); var nativePage = new NativePage { MyControl = element.Object }; var page = new SeleniumPage(nativePage); IPropertyData propertyData; var result = page.TryGetElement("MyControl", out propertyData); Assert.IsNotNull(nativePage.MyControl); Assert.AreEqual(true, result); Assert.IsNotNull(propertyData); }
public void TestGetElementTextWhenControlIsTextAreaControl() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("textarea"); element.Setup(e => e.GetAttribute("type")).Returns("textarea"); element.Setup(e => e.GetAttribute("value")).Returns("Input Text Area"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetElementText(element.Object); Assert.AreEqual("Input Text Area", result); element.VerifyAll(); }
public void TestGetElementTextWhenControlIsCheckBoxInputControl() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input "); element.Setup(e => e.GetAttribute("type")).Returns("checkBox"); element.SetupGet(e => e.Selected).Returns(true); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var result = page.GetElementText(element.Object); Assert.AreEqual("True", result); element.VerifyAll(); }
public void TestGetFillMethodForStandardControl() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("div"); element.Setup(e => e.SendKeys("Some Text")); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "Some Text"); element.VerifyAll(); }
public void TestTryGetCorrectElement() { var element = new Mock <IWebElement>(MockBehavior.Strict); var nativePage = new NativePage { MyControl = element.Object }; var page = new SeleniumPage(nativePage, null); IPropertyData propertyData; var result = page.TryGetElement("MyControl", out propertyData); Assert.IsNotNull(nativePage.MyControl); Assert.AreEqual(true, result); Assert.IsNotNull(propertyData); }
public void TestGetFillMethodForRadioButtonControl() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input"); element.Setup(e => e.GetAttribute("type")).Returns("radio"); this.SetupClick(element); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "true"); element.Verify(e => e.Click(), Times.Exactly(2)); element.VerifyAll(); }
public void TestGetFillMethodForCheckboxControl() { var element = new Mock <IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input"); element.Setup(e => e.GetAttribute("type")).Returns("checkbox"); element.SetupGet(e => e.Selected).Returns(false); this.SetupClick(element); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, null); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "true"); element.VerifyAll(); }
public void TestHighlightElementWhenDriverNotSupportedDoesNotThowException() { const string DefaultStyle = "color: blue;"; var element = new Mock <IWebElement>(MockBehavior.Strict); element.Setup(e => e.GetAttribute("style")).Returns(DefaultStyle); var item = element.Object; var webDriver = new Mock <IWebDriver>(MockBehavior.Strict); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage, webDriver.Object); page.Highlight(item); element.VerifyAll(); webDriver.VerifyAll(); }
public void ThenTheIntervalOrderTextShouldBeDisplayed(string intervalOrder) { SeleniumPage.Should().WaitFor(x => x.DisplayRows.Any()).Then() .DisplayRows.Should().AllBeFound() .And.ContainText(intervalOrder?.ToUpperInvariant() switch { "6-27" => new IntervalOrder627().DisplayRows, "6-30" => new IntervalOrder630().DisplayRows, "6Z13" => new IntervalOrder6Z13().DisplayRows, "6Z23" => new IntervalOrder6Z23().DisplayRows, "6Z28" => new IntervalOrder6Z28().DisplayRows, "6Z29" => new IntervalOrder6Z29().DisplayRows, "6Z42" => new IntervalOrder6Z42().DisplayRows, "6Z45" => new IntervalOrder6Z45().DisplayRows, "6Z49" => new IntervalOrder6Z49().DisplayRows, "6Z50" => new IntervalOrder6Z50().DisplayRows, _ => throw new ArgumentOutOfRangeException(nameof(intervalOrder), intervalOrder, $"{intervalOrder} is not a known value") });
public void CalssInit() { var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Manage().Window.Maximize(); _loginPage = new LoginPage(driver); _regPage = new RegistrationPage(driver); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); _user = UserFactory.CreateValidUser(); _navPage = new NavigationBarPage(driver); _qaPage = new QaAutomationPage(driver); _gsPage = new GoogleSearchPage(driver); _seleniumsearchPage = new SeleniumSearchPage(driver); _selPage = new SeleniumPage(driver); }
public void TestGetFillMethodForMultipleSelectControl() { var option = new Mock<IWebElement>(MockBehavior.Strict); option.SetupGet(o => o.Selected).Returns(false); this.SetupClick(option); var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("select"); element.Setup(e => e.GetAttribute("multiple")).Returns("true"); element.Setup(e => e.FindElements(By.TagName("option"))) .Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object })); element.Setup(e => e.FindElements(By.XPath(".//option[normalize-space(.) = \"Selected Item\"]"))) .Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object })); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "Selected Item"); element.VerifyAll(); }
public void TestGetFillMethodForRadioButtonControl() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input"); element.Setup(e => e.GetAttribute("type")).Returns("radio"); this.SetupClick(element); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "true"); element.Verify(e => e.Click(), Times.Exactly(2)); element.VerifyAll(); }
public void TestGetFillMethodForCheckboxControl() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input"); element.Setup(e => e.GetAttribute("type")).Returns("checkbox"); element.SetupGet(e => e.Selected).Returns(false); this.SetupClick(element); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "true"); element.VerifyAll(); }
public void TestGetFillMethodForStandardInputControl() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input"); element.Setup(e => e.GetAttribute("type")).Returns("text"); element.Setup(e => e.SendKeys("Some Text")); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var fillMethod = page.GetPageFillMethod(null); fillMethod(element.Object, "Some Text"); element.VerifyAll(); }
public void TestGetClearMethod() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.Setup(e => e.Clear()); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var clearMethod = page.GetClearMethod(null); clearMethod(element.Object); element.VerifyAll(); }
public void TestGetClickElement() { var element = new Mock<IWebElement>(MockBehavior.Strict); this.SetupClick(element); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.ClickElement(element.Object); Assert.AreEqual(true, result); element.VerifyAll(); }
public void TestGetClickElementWhenControlIsSelected() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Selected).Returns(true); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.ClickElement(element.Object); Assert.AreEqual(true, result); element.VerifyAll(); }
public void TestGetElementAttributeValueWithValidAttribute() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.Setup(e => e.GetAttribute("href")).Returns("http://myurl.com/page"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetElementAttributeValue(element.Object, "href"); Assert.AreEqual("http://myurl.com/page", result); element.VerifyAll(); }
public void TestWaitForControlExpectExistButIsNot() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Returns(false); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.WaitForElement(element.Object, WaitConditions.Exists, null); Assert.IsFalse(result); element.VerifyAll(); }
public void TestGetElementTextWhenControlIsNotSpecialReturnsTheElementText() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("DIV"); element.SetupGet(e => e.Text).Returns("Normal Text"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetElementText(element.Object); Assert.AreEqual("Normal Text", result); element.VerifyAll(); }
public void TestElementEnabledCheckWhenStaleElementReferenceReturnsFalse() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Throws<StaleElementReferenceException>(); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.ElementEnabledCheck(element.Object); Assert.IsFalse(result); element.VerifyAll(); }
public void TestElementEnabledCheckWhenElementNotVisibleExceptionReturnsFalse() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Throws<ElementNotVisibleException>(); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.ElementEnabledCheck(element.Object); Assert.AreEqual(false, result); element.VerifyAll(); }
public void TestWaitForControlNotEnabled() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Enabled).Returns(false); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.WaitForElement(element.Object, WaitConditions.NotEnabled, null); Assert.IsTrue(result); element.VerifyAll(); }
public void TestGetElementTextWhenControlASelectControlReturnsTheSelectedItemText() { var option = new Mock<IWebElement>(MockBehavior.Strict); option.SetupGet(o => o.Selected).Returns(true); option.SetupGet(o => o.Text).Returns("Selected Item"); var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("select"); element.Setup(e => e.GetAttribute("multiple")).Returns("false"); element.Setup(e => e.FindElements(By.TagName("option"))) .Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object })); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetElementText(element.Object); Assert.AreEqual("Selected Item", result); element.VerifyAll(); }
/// <summary> /// Sets up the wait for element. /// </summary> /// <param name="seleniumPage">The selenium page.</param> protected void SetupToWaitForElement(SeleniumPage seleniumPage) { seleniumPage.ExecuteWithElementLocateTimeout = (TimeSpan t, Action work) => work(); seleniumPage.EvaluateWithElementLocateTimeout = (TimeSpan t, Func<bool> work) => { return work(); }; }
public void TestGetElementTextWhenControlIsTextAreaControl() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("textarea"); element.Setup(e => e.GetAttribute("type")).Returns("textarea"); element.Setup(e => e.GetAttribute("value")).Returns("Input Text Area"); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetElementText(element.Object); Assert.AreEqual("Input Text Area", result); element.VerifyAll(); }
public void TestElementExistsCheckWhenDisplayedReturnsTrue() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.Displayed).Returns(true); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.ElementExistsCheck(element.Object); Assert.AreEqual(true, result); element.VerifyAll(); }
public void TestGetElementTextWhenControlIsCheckBoxInputControl() { var element = new Mock<IWebElement>(MockBehavior.Strict); element.SetupGet(e => e.TagName).Returns("input "); element.Setup(e => e.GetAttribute("type")).Returns("checkBox"); element.SetupGet(e => e.Selected).Returns(true); var nativePage = new NativePage(); var page = new SeleniumPage(nativePage); var result = page.GetElementText(element.Object); Assert.AreEqual("True", result); element.VerifyAll(); }