Beispiel #1
0
        public Boolean processSelenese(Selenium_Test_Trinome testCommand, int testCmdCnt)
        {
            DateTime startTime = System.DateTime.UtcNow;
            DateTime stopTime = System.DateTime.UtcNow;

            if (testCommand.getCommand() == ":comment:")
            {
                this.updateCommandStatus(testCommand.getId(), 1, startTime, stopTime, "");
                return true;
            }

            if (this.testHadError == true)
            {
                this.updateCommandStatus(testCommand.getId(), 0, startTime, stopTime, "Command not executed: Failure already occurred");
                return false;
            }

            if (this.seleneseMethods.ContainsKey(testCommand.getCommand()))
            {
                SeleneseCommand cmd = (SeleneseCommand)this.seleneseMethods[testCommand.getCommand()];

                testCommand.interpolateSeleneseVariables(this.webDriver, this.testVariables);

                // Found the command in the vendor commands.
                String[] args;

                if (testCommand.getTarget().Length > 0 && testCommand.getValue().Length > 0)
                {
                    args = new String[2];
                    args[0] = testCommand.getTarget();
                    args[1] = testCommand.getValue();
                }
                else if (testCommand.getTarget().Length > 0)
                {
                    args = new String[1];
                    args[0] = testCommand.getTarget();
                }
                else
                {
                    args = null;
                }

                String message = "Working...";

                this.updateCommandStatus(testCommand.getId(), -1, startTime, stopTime, message);

                try
                {
                    DateTime s1 = System.DateTime.UtcNow;
                    cmd.Apply(this.webDriver, args);
                    DateTime s2 = System.DateTime.UtcNow;

                    stopTime = System.DateTime.UtcNow;
                    this.updateCommandStatus(testCommand.getId(), 1, startTime, stopTime, "");

                    this.waitForNextCommandTarget(testCommand, testCmdCnt, startTime, stopTime);

                    return true;
                }
                catch (Exception e)
                {
                    message = "failed: " + e.Message + " stacktrace: " + e.StackTrace.ToString();
                    stopTime = System.DateTime.UtcNow;
                    this.updateCommandStatus(testCommand.getId(), 0, startTime, stopTime, message);
                    this.testHadError = true;
                    return false;
                }
            }

            this.testHadError = true;
            this.updateCommandStatus(testCommand.getId(), 0, startTime, stopTime, "Command not executed: Unimplemented selenese.");
            return false;
        }
Beispiel #2
0
        private void waitForNextCommandTarget(Selenium_Test_Trinome testCommand, int testCmdCnt, DateTime startTime, DateTime stopTime)
        {
            CTM_PageLoadWaiter pageLoad = new CTM_PageLoadWaiter(this.webDriver, 30000);

            ArrayList blockingCommands = new ArrayList();
            blockingCommands.Add("click");
            blockingCommands.Add("clickAndWait");
            blockingCommands.Add("open");

            ArrayList nextCommandLimiters = new ArrayList();
            nextCommandLimiters.Add("open");
            nextCommandLimiters.Add("verifySelectedLabel");
            nextCommandLimiters.Add("waitForPageToLoad"); // This is somewhat implicit with our new design.

            if (blockingCommands.Contains(testCommand.getCommand()))
            {

                // Find the next valid command.
                Selenium_Test_Trinome nextCommand = this.findNextTestCommand(testCmdCnt);

                // Set the wait timeout limit to 300s which is the default selenium timeout too.
                int waitTimeout = 300;

                // JEO: Pretty sure we need to limit this here to type and other commands
                if (nextCommand != null && nextCommandLimiters.Contains(nextCommand.getCommand()) == false)
                {
                    nextCommand.interpolateSeleneseVariables(this.webDriver,this.testVariables);

                    if (nextCommand.getTarget().Contains("${") == true || nextCommand.getValue().Contains("${") == true)
                    {
                        // Okay we're most likely in a logic loop here where a store command happenes before
                        // a use of the variable.
                        return;
                    }

                    if (nextCommand.getCommand() == "store" ) {
                        return;
                    }

                    double waitedSeconds = this.waitedSeconds(startTime, stopTime);

                    while( waitedSeconds < waitTimeout ) {

                        if (waitedSeconds > 60)
                        {

                        }

                        stopTime = System.DateTime.UtcNow;
                        waitedSeconds = this.waitedSeconds(startTime, stopTime);

                        this.updateCommandStatus(testCommand.getId(), 1, startTime, stopTime, "Waiting for next target..");

                        try
                        {
                            if (nextCommand.getCommand() == "verifyTextPresent" || nextCommand.getCommand() == "assertTextPresent")
                            {
                                String[] args = new String[2];
                                args[0] = nextCommand.getTarget();
                                args[1] = "";

                                CTM_IsTextPresent textPresentCmd = new CTM_IsTextPresent();

                                if ( (bool) textPresentCmd.Apply(this.webDriver, args) == true ) {
                                    stopTime = System.DateTime.UtcNow;
                                    this.updateCommandStatus(testCommand.getId(), 1, startTime, stopTime, "");
                                    return;
                                }

                            }
                            else
                            {
                                IWebElement elem = this.elementFinder.FindElement(this.webDriver, nextCommand.getTarget());
                                if (elem != null)
                                {

                                    stopTime = System.DateTime.UtcNow;
                                    this.updateCommandStatus(testCommand.getId(), 1, startTime, stopTime, "");
                                    return;
                                }
                            }

                            System.Threading.Thread.Sleep(1000);

                        }
                        catch
                        {
                            // It's okay if this fails we won't do anyting with it anyways.
                        }

                    }

                    stopTime = System.DateTime.UtcNow;
                    this.updateCommandStatus(testCommand.getId(), 0, startTime, stopTime, "Failed to find the next element within a acceptable time period. We waited " + waitedSeconds + "  seconds for nextCommand.Target: " + nextCommand.getTarget());
                    this.testHadError = true;
                    return;

                } // Skinning the cat differntly by avoiding the use of waiter()

            }

            return;
        }