Beispiel #1
0
        public override XElement Act()
        {
            var sr = new StepResult(this);
            if (UIObject == null||UIObject.Count == 0)
            {
                sr.Error("Expected UI Object is not found!");
            }
            else
            {
                var text = UIObject[0];
                try
                {
                    text.Clear();
                }
                catch (Exception)
                {
                    //some objects cannot be cleared, like hidden, file.upload, so ignore this error
                    if (!string.IsNullOrEmpty(XPath) && !string.IsNullOrEmpty(Data))
                    {
                        Browser.ExecuteJavaScript("document.evaluate('" + XPath.Replace("'", "\\\"") + "',document,null,9,null).singleNodeValue.value = '" + Data + "';");
                        return sr.GetResult();
                    }
                }
                if (!string.IsNullOrEmpty(Data))
                {

                    text.SendKeys(Data);
                }
            }
            return sr.GetResult();
        }
Beispiel #2
0
        public override XElement Act()
        {
            var sr = new StepResult(this);

            //because it is .net, so we can only work on dos
            DosCommand(Data);
            return sr.GetResult();
        }
Beispiel #3
0
        public override XElement Act()
        {
            var sr = new StepResult(this);
            if (UIObject == null || UIObject.Count == 0)
            {
                sr.Error("Expected UI Object is not found!");
            }

            return sr.GetResult();
        }
Beispiel #4
0
 public override XElement Act()
 {
     var sr = new StepResult(this);
     var time = 17;
     if (!string.IsNullOrEmpty(Data))
     {
         time = Convert.ToInt32(Data);
     }
     Thread.Sleep(time*1000);
     return sr.GetResult();
 }
Beispiel #5
0
 public override XElement Act()
 {
     var sr = new StepResult(this);
     if (UIObject == null || UIObject.Count == 0)
     {
         sr.Error("Expected UI Object is not found!");
     }
     else
     {
         var select = new SelectElement(UIObject[0]);
         if (!string.IsNullOrEmpty(Data))
         {
             select.SelectByText(Data);
             //select.FindElement(By.CssSelector("option[value='3']")).Selected;
         }
     }
     return sr.GetResult();
 }
Beispiel #6
0
        public override XElement Act()
        {
            var sr = new StepResult(this);
            if (UIObject == null || UIObject.Count == 0)
            {
                sr.Error("Expected Table is not found!");
            }
            else
            {
                var target = UIObject[0];
                var rows = target.FindElements(By.TagName("tr"));
                if (rows.Any(VerifyRowMatched))
                {
                    return sr.GetResult();
                }
                sr.Error("Expected Row not found, Data["+Data+"]");

            }
            return sr.GetResult();
        }
Beispiel #7
0
 public override XElement Act()
 {
     var sr = new StepResult(this);
     if (UIObject.Count == 0)
     {
         sr.Error("Expected UI Object is not found!");
     }
     else
     {
         if (string.IsNullOrEmpty(Data))
             UIObject[0].Click();
         else
         {
             var toCheck = Convert.ToBoolean(Data);
             var checkStatus = UIObject[0].Selected;
             if (toCheck && !checkStatus || !toCheck && checkStatus)
                 UIObject[0].Click();
         }
     }
     return sr.GetResult();
 }
Beispiel #8
0
        public override XElement Act()
        {
            var sr = new StepResult(this);
            if (UIObject == null || UIObject.Count == 0)
            {
                sr.Error("Expected UI Object is not found!");
            }
            else
            {
                var target = UIObject[0];
                //Data should look like text=>value
                if (!string.IsNullOrEmpty(Data))
                {
                    sr.Error("Please define variable and attribute.");
                    return sr.GetResult();
                }
                if (Data.Contains("=>"))
                {
                    var pos = Data.IndexOf("=>", StringComparison.Ordinal);
                    try
                    {
                        var attr = Data.Substring(0, pos);
                        var expected = Data.Substring(pos + 2);
                        var actual = target.GetAttribute(attr);
                        if(!expected.Trim().Equals(actual.Trim()))
                            sr.Error("Expected["+expected+"]<>Actual["+actual+"]");
                    }
                    catch (Exception ex)
                    {
                        sr.Error(ExceptionHelper.FormatStackTrace("Get attribute Value Failed:", ex));
                    }
                }
                else
                {
                    VerifyWebElement(Data, target);
                }

            }
            return sr.GetResult();
        }
Beispiel #9
0
        public override XElement Act()
        {
            var sr = new StepResult(this);
            if (UIObject == null || UIObject.Count == 0)
            {
                sr.Error("Expected UI Object is not found!");
            }
            else
            {
                var target = UIObject[0];
                //Data should look like text=>variable
                if (string.IsNullOrEmpty(Data))
                {
                    sr.Error("Please define variable and attribute.");
                    return sr.GetResult();
                }
                if (!Data.Contains("=>"))
                {
                    sr.Error("The correct format for this action is 'attribute=>variable', e.g.: value=>currentValue");
                    return sr.GetResult();
                }
                var pos = Data.IndexOf("=>", StringComparison.Ordinal);
                try
                {
                    var attr = Data.Substring(0, pos);
                    var variable = Data.Substring(pos + 2);
                    var value = target.GetAttribute(attr);
                    sr.GetResult().SetAttributeValue(variable,value);
                }
                catch (Exception ex)
                {
                    sr.Error(ExceptionHelper.FormatStackTrace("GetValue Failed:", ex));
                }

            }
            return sr.GetResult();
        }
Beispiel #10
0
        public override XElement Act()
        {
            var sr = new StepResult(this);

            if (UIObject == null || UIObject.Count == 0)
            {
                sr.Error("Expected UI Object is not found!");
            }
            else
            {
                var target = UIObject[0];
                //Data should look like text=>variable
                if (string.IsNullOrEmpty(Data))
                {
                    sr.Error("Please define variable and attribute.");
                    return(sr.GetResult());
                }
                if (!Data.Contains("=>"))
                {
                    sr.Error("The correct format for this action is 'attribute=>variable', e.g.: value=>currentValue");
                    return(sr.GetResult());
                }
                var pos = Data.IndexOf("=>", StringComparison.Ordinal);
                try
                {
                    var attr     = Data.Substring(0, pos);
                    var variable = Data.Substring(pos + 2);
                    var value    = target.GetAttribute(attr);
                    sr.GetResult().SetAttributeValue(variable, value);
                }
                catch (Exception ex)
                {
                    sr.Error(ExceptionHelper.FormatStackTrace("GetValue Failed:", ex));
                }
            }
            return(sr.GetResult());
        }
Beispiel #11
0
        public override XElement Act()
        {
            var sr = new StepResult(this);

            return(sr.GetResult());
        }
Beispiel #12
0
 public override XElement Act()
 {
     var sr = new StepResult(this);
     Browser.CloseBrowser();
     return sr.GetResult();
 }