Ejemplo n.º 1
0
        Given_verification_on_IClickable_and_take_screenshot_is_true_When_verification_succeeds_Then_screenshot_is_not_taken
            ()
        {
            var driver            = Substitute.For <IWebDriver>();
            var driverEnvironment = Substitute.For <IDriverEnvironment>();
            var settings          = Substitute.For <ISettings>();
            var session           = Substitute.For <Session>(driverEnvironment);

            driverEnvironment.CreateWebDriver().Returns(driver);

            settings.CaptureScreenOnVerificationFailure.Returns(true);

            session.Settings.Returns(settings);

            var clickable = new TestClickable
            {
                Session = session,
                Text    = "The right text"
            };

            clickable.Verify(x => x.Text == "The right text");

            session.DidNotReceiveWithAnyArgs().CaptureScreen();

            session.End();
        }
Ejemplo n.º 2
0
        Given_verification_on_IClickable_and_take_screenshot_is_true_When_verification_fails_Then_screenshot_is_taken
            ()
        {
            var driver            = Substitute.For <IWebDriver>();
            var driverEnvironment = Substitute.For <IDriverEnvironment>();
            var settings          = Substitute.For <ISettings>();
            var session           = Substitute.For <Session>(driverEnvironment);

            var clickable = new TestClickable
            {
                Session = session,
                Text    = "Not the right text"
            };

            driverEnvironment.CreateWebDriver().Returns(driver);

            settings.CaptureScreenOnVerificationFailure.Returns(true);

            session.Settings.Returns(settings);

            try
            {
                clickable.Verify(x => x.Text == "The right text");
            }
            catch (VerificationException)
            {
            }

            session.Received()
            .CaptureScreen(Path.Combine(Environment.CurrentDirectory,
                                        string.Format("{0}.png", MethodBase.GetCurrentMethod().GetFullName())));

            session.End();
        }