Beispiel #1
0
        protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
        {
            var selectElement = new SelectElement(element);

            var lowerCommand = command.Parameter.ToLower();
            if (lowerCommand.StartsWith("label="))
            {
                selectElement.SelectByText(command.Parameter.Substring(6));
                return;
            }

            if (lowerCommand.StartsWith("value="))
            {
                selectElement.SelectByValue(command.Parameter.Substring(6));
                return;
            }

            if (lowerCommand.StartsWith("index="))
            {
                selectElement.SelectByIndex(int.Parse(command.Parameter.Substring(6)));
                return;
            }

            selectElement.SelectByText(command.Parameter);
        }
        public CommandResult Execute(IWebDriver driver, CommandDesc command)
        {
            try
            {
                var result = new CommandResult { Command = command };

                var timeout = GetTimeout(command);
                var complexSelector = WebDriverExtensions.GetContainsSelector(command.Selector);
                var by = WebDriverExtensions.GetBy(complexSelector.SimpleSelector);

                var elements = driver.FindElements(by);
                if (elements.Any())
                    driver.WaitForNotElement(by, timeout.GetValueOrDefault(WebDriverExtensions.DEFAULT_TIMEOUT));
                elements = driver.FindElements(by);

                var count = elements.Count();
                if (count > 0)
                    throw new Exception("Element was found.");

                return result;
            }
            catch (Exception ex)
            {
                return new CommandResult
                {
                    Command = command,
                    HasError = true,
                    Comments = ex.Message
                };
            }
        }
Beispiel #3
0
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     if (element.Selected)
     {
         element.Click();
     }
 }
        private int? GetTimeout(CommandDesc command)
        {
            int timeout;
            if (Int32.TryParse(command.Parameter, out timeout))
                return timeout;

            return null;
        }
        protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
        {
            var elementText = element.Text.Trim();
            var searchedText = command.Parameter.Trim();

            if (!elementText.Equals(searchedText))
                throw new Exception("Text does not match. Found: \"" + elementText + "\"");
        }
        public static CommandResult Execute(IWebDriver driver, CommandDesc command)
        {
            var lowerName = command.Name.ToLower();
            if (!Commands.ContainsKey(lowerName))
                return new CommandResult { Command = command, IsSkipped = true };

            command.Parameter = ExpandVariables(command.Parameter);
            command.Selector = ExpandVariables(command.Selector);

            return Commands[lowerName].Execute(driver, command);
        }
 public CommandResult Execute(IWebDriver driver, CommandDesc command)
 {
     try
     {
         var result = new CommandResult { Command = command };
         SuiteExecutor.StoreValue(command.Parameter, command.Selector);
         return result;
     }
     catch (Exception ex)
     {
         return new CommandResult
         {
             Command = command,
             HasError = true,
             Comments = ex.Message
         };
     }
 }
        private IWebElement GetElement(IWebDriver driver, CommandDesc command, CommandResult result)
        {
            var timeout = GetTimeout(command);
            var elements = driver.GetElements(command.Selector, timeout);
            var count = elements.Count();

            if (count == 0)
            {
                result.HasError = true;
                result.Comments = "Element not found.";
            }
            else if (count > 1)
            {
                result.HasWarning = true;
                result.Comments = "More than one element found";
            }

            return elements.FirstOrDefault();
        }
        public CommandResult Execute(IWebDriver driver, CommandDesc command)
        {
            try
            {
                var result = new CommandResult { Command = command };

                var value = ((IJavaScriptExecutor)driver).ExecuteScript("return " + command.Selector);
                Execute(value, command);

                return result;
            }
            catch (Exception ex)
            {
                return new CommandResult
                {
                    Command = command,
                    HasError = true,
                    Comments = ex.Message
                };
            }
        }
        public CommandResult Execute(IWebDriver driver, CommandDesc command)
        {
            try
            {
                var result = new CommandResult { Command = command };
                var element = GetElement(driver, command, result);

                if (result.HasError)
                    return result;
                Execute(driver, element, command);
                return result;
            }
            catch (Exception ex)
            {
                return new CommandResult
                {
                    Command = command,
                    HasError = true,
                    Comments = ex.Message
                };
            }
        }
Beispiel #11
0
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     var action = new Actions(driver);
     action.MoveToElement(element).Click().Perform();
 }
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     SuiteExecutor.StoreValue(command.Parameter, element.Text);
 }
 protected abstract void Execute(IWebDriver driver, IWebElement element, CommandDesc command);
Beispiel #14
0
        internal override void Read(BinaryReaderEx br)
        {
            br.BigEndian = false;

            string magic = br.AssertASCII("fSSL", "fsSL");

            LongFormat    = magic == "fsSL";
            br.VarintLong = LongFormat;

            br.AssertInt32(1);
            br.AssertInt32(1);
            br.AssertInt32(1);
            br.AssertInt32(0x7C);
            int dataSize = br.ReadInt32();

            br.AssertInt32(11);

            br.AssertInt32(LongFormat ? 0x58 : 0x34);
            br.AssertInt32(1);
            br.AssertInt32(LongFormat ? 0x10 : 8);
            int stringCount = br.ReadInt32();

            br.AssertInt32(4);
            br.AssertInt32(0);
            br.AssertInt32(8);
            int functionSpecCount = br.ReadInt32();
            int conditionSize     = br.AssertInt32(LongFormat ? 0x10 : 8);
            int conditionCount    = br.ReadInt32();

            br.AssertInt32(LongFormat ? 0x10 : 8);
            br.AssertInt32(0);
            br.AssertInt32(LongFormat ? 0x18 : 0x10);
            int commandSpecCount = br.ReadInt32();
            int commandSize      = br.AssertInt32(4);
            int commandCount     = br.ReadInt32();
            int passCommandSize  = br.AssertInt32(LongFormat ? 0x10 : 8);
            int passCommandCount = br.ReadInt32();
            int stateSize        = br.AssertInt32(LongFormat ? 0x78 : 0x3C);
            int stateCount       = br.ReadInt32();

            br.AssertInt32(LongFormat ? 0x48 : 0x30);
            int machineCount = br.ReadInt32();

            int stringsOffset = br.ReadInt32();

            br.AssertInt32(0);
            br.AssertInt32(stringsOffset);
            Unk80 = br.ReadInt32();
            br.AssertInt32(dataSize);
            br.AssertInt32(0);
            br.AssertInt32(dataSize);
            br.AssertInt32(0);

            long dataStart = br.Position;

            br.AssertVarint(0);
            long commandSpecOffset = br.ReadVarint();

            br.AssertVarint(commandSpecCount);
            long functionSpecOffset = br.ReadVarint();

            br.AssertVarint(functionSpecCount);
            long machineOffset = br.ReadVarint();

            br.AssertInt32(machineCount);
            UnkB0 = br.ReadInt32s(4);
            if (LongFormat)
            {
                br.AssertInt32(0);
            }
            br.AssertVarint(LongFormat ? 0x58 : 0x34);
            br.AssertVarint(stringCount);

            List <string> strings = new List <string>();

            for (int i = 0; i < stringCount; i++)
            {
                long stringOffset = br.ReadVarint();
                // Char count not needed as all strings are null-terminated
                br.ReadVarint();
                br.StepIn(dataStart + stringOffset);
                string str = br.ReadUTF16();
                br.StepOut();
                strings.Add(str);
            }

            FunctionSpecs = new List <FunctionSpec>();
            for (int i = 0; i < functionSpecCount; i++)
            {
                FunctionSpecs.Add(new FunctionSpec(br, strings));
            }

            Dictionary <long, ConditionDesc> conditions = new Dictionary <long, ConditionDesc>();

            for (int i = 0; i < conditionCount; i++)
            {
                long offset = br.Position - dataStart;
                conditions[offset] = new ConditionDesc(br);
            }

            CommandSpecs = new List <CommandSpec>();
            for (int i = 0; i < commandSpecCount; i++)
            {
                CommandSpecs.Add(new CommandSpec(br, strings));
            }

            Dictionary <long, CommandDesc> commands = new Dictionary <long, CommandDesc>();

            for (int i = 0; i < commandCount; i++)
            {
                long offset = br.Position - dataStart;
                commands[offset] = new CommandDesc(br, strings);
            }
            if (LongFormat)
            {
                // Data-start-aligned padding.
                long offset = br.Position - dataStart;
                if (offset % 8 > 0)
                {
                    br.Skip(8 - (int)(offset % 8));
                }
            }

            Dictionary <long, PassCommandDesc> passCommands = new Dictionary <long, PassCommandDesc>();

            for (int i = 0; i < passCommandCount; i++)
            {
                long offset = br.Position - dataStart;
                passCommands[offset] = new PassCommandDesc(br, commands, commandSize);
            }

            Dictionary <long, StateDesc> states = new Dictionary <long, StateDesc>();

            for (int i = 0; i < stateCount; i++)
            {
                long offset = br.Position - dataStart;
                states[offset] = new StateDesc(br, strings, dataStart, conditions, conditionSize, commands, commandSize, passCommands, passCommandSize);
            }

            Machines = new List <MachineDesc>();
            for (int i = 0; i < machineCount; i++)
            {
                Machines.Add(new MachineDesc(br, strings, states, stateSize));
            }

            if (conditions.Count > 0 || commands.Count > 0 || passCommands.Count > 0 || states.Count > 0)
            {
                throw new FormatException("Orphaned ESD descriptions found");
            }
        }
Beispiel #15
0
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     element.SendKeys(command.Parameter);
 }
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
 }
 protected abstract void Execute(object scriptResult, CommandDesc command);
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     if (element.Text.Equals(command.Parameter))
         throw new Exception("Text does match.");
 }
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     if (!element.Selected)
         throw new Exception("Element is not checked.");
 }