Пример #1
0
        public void ShouldParseInstruction_WithAccuracySpecified2()
        {
            var instruction = new WebElementInstruction("1st button like submit like");

            Assert.AreEqual(CompareAccuracy.Partial, instruction.Accuracy);
            Assert.AreEqual("submit like", instruction.SubjectName);
        }
Пример #2
0
        public void ShouldParseInstructionCorrectly4()
        {
            var instruction = new WebElementInstruction("blah blah with bluh bluh");

            Assert.AreEqual("blah blah", instruction.SubjectName);
            Assert.AreEqual("bluh bluh", instruction.With);
        }
Пример #3
0
        public void ShouldParseInstruction_WithAccuracySpecified3()
        {
            var instruction = new WebElementInstruction("1st button 'like submit'");

            Assert.AreEqual(CompareAccuracy.Exact, instruction.Accuracy);
            Assert.AreEqual("like submit", instruction.SubjectName);
        }
Пример #4
0
        public void ShouldParseInstructionCorrectly5()
        {
            var instruction = new WebElementInstruction("2nd button");

            Assert.AreEqual(null, instruction.SubjectName);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
            Assert.AreEqual(1, instruction.Order);
        }
Пример #5
0
        public void ShouldParseInstruction_WithKeyWordSubstring5()
        {
            var instruction = new WebElementInstruction("1st 'inwith' with 'inside'");

            Assert.AreEqual("inwith", instruction.SubjectName);
            Assert.AreEqual(0, instruction.Order);
            Assert.AreEqual("inside", instruction.With);
        }
Пример #6
0
        public void ShouldParseInstruction_WithAccuracySpecified7()
        {
            var instruction = new WebElementInstruction("button like Add to");

            Assert.AreEqual(CompareAccuracy.Partial, instruction.Accuracy);
            Assert.AreEqual("Add to", instruction.SubjectName);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
        }
Пример #7
0
        public void ShouldParseInstruction_Bug2()
        {
            var instruction = new WebElementInstruction("'7 dwarfs' from top");

            Assert.AreEqual(null, instruction.Order);
            Assert.AreEqual("7 dwarfs", instruction.SubjectName);
            Assert.AreEqual(SearchDirection.DownFromTopEdge, instruction.Direction);
        }
Пример #8
0
        public void ShouldParseInstruction_WithNumber()
        {
            var instruction = new WebElementInstruction("12 records");

            Assert.AreEqual(CompareAccuracy.Exact, instruction.Accuracy);
            Assert.AreEqual("12 records", instruction.SubjectName);
            Assert.AreEqual(null, instruction.Order);
            Assert.AreEqual(null, instruction.Direction);
        }
Пример #9
0
 private void MapSyntaxToSemantics(WebElementInstruction instruction)
 {
     SubjectName = instruction.SubjectName ?? SubjectName;
     Locale      = instruction.Locale ?? Locale;
     Direction   = instruction.Direction ?? Direction;
     Order       = instruction.Order ?? Order;
     TagNames    = instruction.TagNames ?? TagNames;
     spec        = instruction;
 }
Пример #10
0
        public void ShouldParseInstruction_Bug()
        {
            var instruction = new WebElementInstruction("2nd 'Input Name' from top");

            Assert.AreEqual(1, instruction.Order);
            Assert.AreEqual(CompareAccuracy.Exact, instruction.Accuracy);
            Assert.AreEqual("Input Name", instruction.SubjectName);
            Assert.AreEqual(SearchDirection.DownFromTopEdge, instruction.Direction);
        }
Пример #11
0
        public void ShouldParseInstruction_WithKeyWordSubstring2()
        {
            var instruction = new WebElementInstruction("1st Input");

            Assert.AreEqual(null, instruction.SubjectName);
            Assert.AreEqual(0, instruction.Order);
            Assert.AreEqual(WebElementType.Input, instruction.SubjectType);
            Assert.AreEqual(null, instruction.Direction);
        }
Пример #12
0
        public void ShouldParseInstruction_WithKeyWordSubstring3()
        {
            var instruction = new WebElementInstruction("1st Input s from left");

            Assert.AreEqual("s", instruction.SubjectName);
            Assert.AreEqual(0, instruction.Order);
            Assert.AreEqual(WebElementType.Input, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.RightFromLeftEdge, instruction.Direction);
        }
Пример #13
0
        public void ShouldParseInstructionCorrectly3()
        {
            var instruction = new WebElementInstruction("something long above something even longer with ' an absurdely long text with numb3rs and stuff'");

            Assert.AreEqual("something long", instruction.SubjectName);
            Assert.AreEqual("something even longer", instruction.Locale);
            Assert.AreEqual(SearchDirection.AboveAnotherElement, instruction.Direction);
            Assert.AreEqual("an absurdely long text with numb3rs and stuff", instruction.With);
        }
Пример #14
0
        public void ShouldParseInstructionCorrectly8()
        {
            var instruction = new WebElementInstruction("4. button from left");

            Assert.AreEqual(3, instruction.Order);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.RightFromLeftEdge, instruction.Direction);
            Assert.AreEqual(null, instruction.Locale);
        }
Пример #15
0
        public void ShouldParseInstruction_WithAccuracySpecified6()
        {
            var instruction = new WebElementInstruction("button like 'Add to' left from 'Something'");

            Assert.AreEqual(CompareAccuracy.Partial, instruction.Accuracy);
            Assert.AreEqual("Add to", instruction.SubjectName);
            Assert.AreEqual("Something", instruction.Locale);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.LeftFromAnotherElement, instruction.Direction);
        }
Пример #16
0
        public void ShouldParseInstruction_WithAccuracySpecified4()
        {
            var instruction = new WebElementInstruction("3. button like 'Add to'");

            Assert.AreEqual(2, instruction.Order);
            Assert.AreEqual(CompareAccuracy.Partial, instruction.Accuracy);
            Assert.AreEqual("Add to", instruction.SubjectName);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
            Assert.AreEqual(null, instruction.Direction);
        }
Пример #17
0
 private void MapSyntaxToSemantics(WebElementInstruction instruction)
 {
     SubjectName = instruction.SubjectName ?? SubjectName;
     Locale      = instruction.Locale ?? Locale;
     Direction   = instruction.Direction ?? Direction;
     Order       = instruction.Order ?? Order;
     TagNames    = instruction.TagNames ?? TagNames;
     spec        = instruction;
     ExactMatch  = instruction.Accuracy != CompareAccuracy.Partial;
 }
Пример #18
0
        public void ShouldParseInstructionCorrectly7()
        {
            var instruction = new WebElementInstruction("4. link from right");

            Assert.AreEqual(3, instruction.Order);
            Assert.AreEqual(null, instruction.SubjectName);
            Assert.AreEqual(WebElementType.Link, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.LeftFromRightEdge, instruction.Direction);
            Assert.AreEqual(null, instruction.Locale);
        }
Пример #19
0
        public void ShouldParseInstruction_WithArea()
        {
            var instruction = new WebElementInstruction("1st Input inside left center");

            Assert.AreEqual(null, instruction.SubjectName);
            Assert.AreEqual(0, instruction.Order);
            Assert.AreEqual(WebElementType.Input, instruction.SubjectType);
            Assert.AreEqual(null, instruction.Direction);
            Assert.AreEqual("left center", instruction.Area);
        }
Пример #20
0
        public void ShouldParseInstruction_WithAccuracySpecified()
        {
            var instruction = new WebElementInstruction("like 'something long' above 'something even longer' with ' an absurdely long text with numb3rs and stuff'");

            Assert.AreEqual(CompareAccuracy.Partial, instruction.Accuracy);
            Assert.AreEqual("something long", instruction.SubjectName);
            Assert.AreEqual("something even longer", instruction.Locale);
            Assert.AreEqual(SearchDirection.AboveAnotherElement, instruction.Direction);
            Assert.AreEqual("an absurdely long text with numb3rs and stuff", instruction.With);
        }
Пример #21
0
        public void ShouldParseInstructionCorrectly6b()
        {
            var instruction = new WebElementInstruction("2nd textfield 4 blah 4 left from Password with 'Hello'");

            Assert.AreEqual(1, instruction.Order);
            Assert.AreEqual(WebElementType.Input, instruction.SubjectType);
            Assert.AreEqual("4 blah 4", instruction.SubjectName);
            Assert.AreEqual(SearchDirection.LeftFromAnotherElement, instruction.Direction);
            Assert.AreEqual("Password", instruction.Locale);
            Assert.AreEqual("Hello", instruction.With);
        }
Пример #22
0
        public void ShouldParseInstructionCorrectly10()
        {
            var instruction = new WebElementInstruction("223421th input from bottom with flowers");

            Assert.AreEqual(223420, instruction.Order);
            Assert.AreEqual(null, instruction.SubjectName);
            Assert.AreEqual(WebElementType.Input, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.UpFromBottomEdge, instruction.Direction);
            Assert.AreEqual(null, instruction.Locale);
            Assert.AreEqual("flowers", instruction.With);
        }
Пример #23
0
        public void ShouldParseInstructionCorrectly11()
        {
            var instruction = new WebElementInstruction("1st button 'blah' from bottom with flowers");

            Assert.AreEqual(0, instruction.Order);
            Assert.AreEqual("blah", instruction.SubjectName);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.UpFromBottomEdge, instruction.Direction);
            Assert.AreEqual(null, instruction.Locale);
            Assert.AreEqual("flowers", instruction.With);
        }
Пример #24
0
        public void ShouldParseInstructionCorrectly1()
        {
            Assert.AreEqual("blah", new WebElementInstruction("blah").SubjectName);

            var instruction = new WebElementInstruction("blah left from bleh with aa");

            Assert.AreEqual("blah", instruction.SubjectName);
            Assert.AreEqual("bleh", instruction.Locale);
            Assert.AreEqual(SearchDirection.LeftFromAnotherElement, instruction.Direction);
            Assert.AreEqual("aa", instruction.With);
        }
Пример #25
0
        public void ShouldParseInstruction_WithArea2()
        {
            var instruction = new WebElementInstruction("45th button like 'Add to' left from 'Something' inside Marshmallow village with Green Butter");

            Assert.AreEqual(CompareAccuracy.Partial, instruction.Accuracy);
            Assert.AreEqual(44, instruction.Order);
            Assert.AreEqual("Add to", instruction.SubjectName);
            Assert.AreEqual("Something", instruction.Locale);
            Assert.AreEqual(WebElementType.Button, instruction.SubjectType);
            Assert.AreEqual(SearchDirection.LeftFromAnotherElement, instruction.Direction);
            Assert.AreEqual("Green Butter", instruction.With);
            Assert.AreEqual("Marshmallow village", instruction.Area);
        }
Пример #26
0
        public void MapRichSyntaxToSemantics(WebElementInstruction instruction)
        {
            Order                  = instruction.Order ?? Order;
            SearchedTagNames       = instruction.TagNames ?? SearchedTagNames;
            SearchedType           = instruction.SubjectType ?? SearchedType;
            VisibleTextOfTheButton = instruction.SubjectName ?? VisibleTextOfTheButton;
            Direction              = instruction.Direction ?? Direction;
            NeighbourToLookFrom    = instruction.Locale ?? NeighbourToLookFrom;

            if (new[]
            {
                SearchDirection.AboveAnotherElement,
                SearchDirection.BelowAnotherElement,
                SearchDirection.RightFromAnotherElement,
                SearchDirection.LeftFromAnotherElement,
            }.Contains(Direction))
            {
                LookForOrthogonalNeighboursOnly = true;
            }

            _instruction = instruction;
        }
Пример #27
0
 public override string ToString()
 {
     return($"Click {(Order+1).ToOrdinalString()} {(SearchedType == default(WebElementType) ? "" : SearchedType.ToString())} {VisibleTextOfTheButton} {(Direction==default(SearchDirection)?"":WebElementInstruction.GetDescription(Direction))} {NeighbourToLookFrom}");
 }