コード例 #1
0
 public void WhenISelectTheVectorsButton(int vector)
 {
     SeleniumPage.Should().BeFound()
     .Then().RadioButton(vector)
     .Should().BeFound()
     .Then().Click();
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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)));
            }
        }
    }
コード例 #5
0
        public void TestGetNativePage()
        {
            var nativePage = new NativePage();
            var page = new SeleniumPage(nativePage);

            var result = page.GetNativePage<NativePage>();
            Assert.AreSame(nativePage, result);
        }
コード例 #6
0
 public void SetUp()
 {
     Initialize();
     _googleHomePage    = new GoogleHome(Driver);
     _googleResultsPage = new GoogleSearchResults(Driver);
     _seleniumPage      = new SeleniumPage(Driver);
     _googleHomePage.NavigateTo();
 }
コード例 #7
0
        public void TestGetPageType()
        {
            var nativePage = new NativePage();
            var page = new SeleniumPage(nativePage);

            var result = page.PageType;
            Assert.AreEqual(typeof(NativePage), result);
        }
コード例 #8
0
        public void TestGetNativePage()
        {
            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, null);

            var result = page.GetNativePage <NativePage>();

            Assert.AreSame(nativePage, result);
        }
コード例 #9
0
        public void TestGetPageType()
        {
            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, null);

            var result = page.PageType;

            Assert.AreEqual(typeof(NativePage), result);
        }
コード例 #10
0
        public SeleniumPage NavigateToSeleniumPage()
        {
            LinkFooter.Click();
            SeleniumPage seleniumPage = new SeleniumPage(Driver);

            Driver.SwitchTo().Window(Driver.WindowHandles.Last());
            WaitTillSeleniumPageIsLoaded();

            return(seleniumPage);
        }
コード例 #11
0
ファイル: SetsSteps.cs プロジェクト: WyattC16/MusicSetTheory
 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();
 }
コード例 #12
0
        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();
        }
コード例 #13
0
        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();
        }
コード例 #14
0
        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();
        }
コード例 #15
0
        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();
        }
コード例 #16
0
        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();
        }
コード例 #17
0
        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();
        }
コード例 #18
0
        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();
        }
コード例 #19
0
        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();
        }
コード例 #20
0
        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();
        }
コード例 #21
0
        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();
        }
コード例 #22
0
        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();
        }
コード例 #23
0
        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();
        }
コード例 #24
0
        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();
        }
コード例 #25
0
        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);
        }
コード例 #26
0
        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();
        }
コード例 #27
0
        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();
        }
コード例 #28
0
        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();
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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();
        }
コード例 #31
0
        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();
        }
コード例 #32
0
        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();
        }
コード例 #33
0
 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")
     });
コード例 #34
0
        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);
        }
コード例 #35
0
        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();
        }
コード例 #36
0
        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();
        }
コード例 #37
0
        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();
        }
コード例 #38
0
        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();
        }
コード例 #39
0
        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();
        }
コード例 #40
0
        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();
        }
コード例 #41
0
        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();
        }
コード例 #42
0
        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();
        }
コード例 #43
0
        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();
        }
コード例 #44
0
        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();
        }
コード例 #45
0
        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();
        }
コード例 #46
0
        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();
        }
コード例 #47
0
        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();
        }
コード例 #48
0
        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();
        }
コード例 #49
0
 /// <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(); };
 }
コード例 #50
0
        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();
        }
コード例 #51
0
        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();
        }
コード例 #52
0
        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();
        }