예제 #1
0
 /// <summary>
 /// Clear stashed command by reporting it to TestProject.
 /// </summary>
 public void ClearStash()
 {
     if (this.stashedCommand != null)
     {
         this.SendCommandToAgent(this.stashedCommand.Command, this.stashedCommand.Result, this.stashedCommand.Passed);
         this.stashedCommand = null;
     }
 }
예제 #2
0
        /// <summary>
        /// Report an executed WebDriver command and its result to TestProject.
        /// </summary>
        /// <param name="command">The WebDriver <see cref="Command"/> to report.</param>
        /// <param name="response">The <see cref="Response"/> from the WebDriver server upon sending the command.</param>
        public void ReportCommand(Command command, Response response)
        {
            bool isQuitCommand = command.Name.Equals(DriverCommand.Quit);

            if (!this.AutoTestReportsDisabled)
            {
                this.ReportTest(isQuitCommand);
            }

            if (isQuitCommand)
            {
                var instance = AgentClient.GetInstance();

                // Send SpecFlow test report, if exists.
                if (instance.SpecFlowTestReport != null)
                {
                    instance.ReportTest(instance.SpecFlowTestReport);
                }

                // Do not report Quit() command to avoid creating a new test in the reports
                return;
            }

            // If the command is IsDisplayed, the passed value we report to agent should be whether the element is visible or not.
            bool passed = response.IsPassed();

            if (CommandHelper.IsDisplayedCommand(command) && passed)
            {
                passed = bool.Parse(response.Value.ToString());
            }

            if (StackTraceHelper.Instance.IsRunningInsideWait())
            {
                // If we are running an "is invisible" type command, we need to invert the result of the command set.
                // This means that checks of Displayed property are inverted, and failure to find the element is actually a success.
                // In W3C this is an ExecuteScript command, and in OSS it is IsElementDisplayed
                if (StackTraceHelper.Instance.IsInvisibleCondition() && (command.Name.Equals(DriverCommand.ExecuteScript) || !passed))
                {
                    passed = !passed;
                }

                // Save the command
                var stashedCommand = new StashedCommand(command, response.Value, passed);
                this.stashedCommands[$"{command.Name}_{command.ParametersAsJsonString}"] = stashedCommand;

                // Do not report the command right away if it's executed inside a WebDriverWait
                return;
            }

            // Send all stashed command first.
            this.ClearStash();

            // If we have a previously stashed command to report, report it first.
            this.SendCommandToAgent(command, response.Value, response.IsPassed());
        }
예제 #3
0
        /// <summary>
        /// Report an executed WebDriver command and its result to TestProject.
        /// </summary>
        /// <param name="command">The WebDriver <see cref="Command"/> to report.</param>
        /// <param name="response">The <see cref="Response"/> from the WebDriver server upon sending the command.</param>
        public void ReportCommand(Command command, Response response)
        {
            bool isQuitCommand = command.Name.Equals(DriverCommand.Quit);

            if (!this.AutoTestReportsDisabled)
            {
                this.ReportTest(isQuitCommand);
            }

            if (isQuitCommand)
            {
                var instance = AgentClient.GetInstance();

                // Send SpecFlow test report, if exists.
                if (instance.SpecFlowTestReport != null)
                {
                    instance.ReportTest(instance.SpecFlowTestReport);
                }

                // Do not report Quit() command to avoid creating a new test in the reports
                return;
            }

            if (StackTraceHelper.Instance.IsRunningInsideWait())
            {
                // We're only interested in reporting the final FindElement or FindElements call
                // (these are executed by the ExpectedConditions helper methods)
                if (
                    command.Name.Equals(DriverCommand.FindElement) ||
                    command.Name.Equals(DriverCommand.FindElements))
                {
                    this.stashedCommand = new StashedCommand(command, response.Value, response.IsPassed());
                }

                // Do not report the command right away if it's executed inside a WebDriverWait
                return;
            }

            // If we have a previously stashed command to report, report it first.
            if (this.stashedCommand != null)
            {
                this.SendCommandToAgent(this.stashedCommand.Command, this.stashedCommand.Result, this.stashedCommand.Passed);
                this.stashedCommand = null;
            }

            this.SendCommandToAgent(command, response.Value, response.IsPassed());
        }
예제 #4
0
 /// <inheritdoc cref="object"/>
 protected bool Equals(StashedCommand other)
 {
     return(object.Equals(this.Command, other.Command) && this.Passed == other.Passed);
 }