Exemple #1
0
        //testować
        public string OpActionSetBatchVariable(Structs.TestStep testStep1)
        {
            if (testStuff.testManager != null)
            {
                IWebElement element = ElementFinder(testStep1);

                Structs.Variable v;

                if ((element.Text != null) && (element.Text != ""))
                {
                    v = new Structs.Variable(testStep1.operationText, element.Text);
                }
                else
                {
                    v = new Structs.Variable(testStep1.operationText, element.GetAttribute("value"));
                }

                if (testStuff.testManager.batchVariables.Where(t => t.name == v.name).Count() == 0)
                {
                    testStuff.testManager.batchVariables.Add(v);
                }
                else
                {
                    testStuff.testManager.batchVariables.Remove(testStuff.variables.Where(t => t.name == v.name).FirstOrDefault());
                    testStuff.testManager.batchVariables.Add(v);
                }

                return("ok");
            }
            else
            {
                return("OpActions.OpActionSetBatchVariable(): test manager is null, are you sure you're running a test batch, not a single test? Using batch variables is allowed only in batch tests.");
            }
        }
Exemple #2
0
        public void OpActionSetVariable(Structs.TestStep testStep1)
        {
            //IWebElement element = testStuff.driver.FindElement(By.XPath(testStep1.xpath));
            IWebElement element = ElementFinder(testStep1);

            Structs.Variable v;

            if ((element.Text != null) && (element.Text != ""))
            {
                v = new Structs.Variable(testStep1.operationText, element.Text);
            }
            else
            {
                v = new Structs.Variable(testStep1.operationText, element.GetAttribute("value"));
            }

            if (testStuff.variables.Where(t => t.name == v.name).Count() == 0)
            {
                testStuff.variables.Add(v);
            }
            else
            {
                testStuff.variables.Remove(testStuff.variables.Where(t => t.name == v.name).FirstOrDefault());
                testStuff.variables.Add(v);
            }
        }
Exemple #3
0
        public string OpActionPresetVariable(Structs.TestStep testStep1)
        {
            string text  = testStep1.operationText;
            string name  = "";
            string value = "";

            try
            {
                name  = text.Substring(0, text.IndexOf('='));
                value = text.Substring(text.IndexOf('=') + 1);
                name  = ClearString(name);
                value = ClearString(value);

                //jeżeli wartość ma być pobrana ze zmiennej batcha, np. text: x={y}
                if (value[0] == '{' && value[value.Length - 1] == '}')
                {
                    value = testStuff.testManager.batchVariables.Where(t => t.name == value.Substring(1, value.Length - 2)).FirstOrDefault().value;
                }
            }
            catch (Exception e)
            {
                return("OpActionPresetVariable(): can't parse \"" + text + "\". Exception:\r\n" + e);
            }

            Structs.Variable v = new Structs.Variable(name, value);

            if (testStuff.variables.Where(t => t.name == v.name).Count() == 0)
            {
                testStuff.variables.Add(v);
            }
            else
            {
                testStuff.variables.Remove(testStuff.variables.Where(t => t.name == v.name).FirstOrDefault());
                testStuff.variables.Add(v);
            }

            return("ok");
        }