Exemple #1
0
 public void WaitNewChanges(string changes, string actionDescription)
 {
     Selenium.Wait(() => GetChanges() != changes, () => "Waiting for changes after {0} in {1}".FormatWith(actionDescription, Prefix));
 }
Exemple #2
0
 public static void StartSelenium()
 {
     Selenium.Start();
     IsSeleniumStarted = true;
 }
Exemple #3
0
 public void SetUpMethods()
 {
     _mainPage = Selenium.OpenSite();
 }
Exemple #4
0
 public void Remove(int index)
 {
     Selenium.FindElement(RemoveLocatorIndex(index)).Click();
 }
Exemple #5
0
 public List <Lite <Entity> > GetDataElements()
 {
     return(Selenium.FindElements(By.CssSelector("#" + this.Prefix + " input[type=checkbox]")).Select(cb => RuntimeInfoProxy.FromFormValue(cb.GetAttribute("value")).ToLite(cb.GetParent().Text)).ToList());
 }
Exemple #6
0
 public void MoveDown(int index)
 {
     Selenium.FindElement(By.CssSelector("#{0}_{1}_btnDown".FormatWith(Prefix, index))).Click();
 }
Exemple #7
0
 public int ItemsCount()
 {
     return((int)(long)Selenium.ExecuteScript("return $('#{0}_sfItemsContainer li.sf-strip-element').length".FormatWith(ItemsContainerLocator)));
 }
Exemple #8
0
 public void SelectIndex(int index)
 {
     WaitChanges(() =>
                 Selenium.FindElement(ComboLocator).SelectElement().SelectByIndex(index + 1),
                 "ComboBox selected");
 }
Exemple #9
0
 public bool HasEntity()
 {
     return(Selenium.IsElementPresent(DivSelector.CombineCss(" *:first-child")));
 }
Exemple #10
0
        public PopupControl <T> View <T>() where T : ModifiableEntity
        {
            Selenium.FindElement(ViewLocator).Click();

            return(base.ViewPopup <T>(null));
        }
Exemple #11
0
 public void SelectLabel(string label)
 {
     WaitChanges(() =>
                 Selenium.FindElement(ComboLocator).SelectElement().SelectByText(label),
                 "ComboBox selected");
 }
Exemple #12
0
 public bool HasEntity()
 {
     return(Selenium.IsElementVisible(LinkLocator));
 }
Exemple #13
0
 protected RuntimeInfoProxy RuntimeInfoInternal(int?index = null)
 {
     return(RuntimeInfoProxy.FromFormValue(Selenium.FindElement(RuntimeInfoLocatorInternal(index)).GetAttribute("value")));
 }
Exemple #14
0
 public string GetChanges()
 {
     return((string)Selenium.ExecuteScript("return $('#{0}').attr('changes')".FormatWith(Prefix)));
 }
Exemple #15
0
 public override int ItemsCount()
 {
     return((int)(long)Selenium.ExecuteScript("return $('#{0}_sfItemsContainer li').length".FormatWith(ItemsContainerLocator)));
 }
Exemple #16
0
 public bool HasEntity(int index)
 {
     return(Selenium.IsElementPresent(OptionIdLocator(index)));
 }
Exemple #17
0
 public void WaitItemLoaded(int index)
 {
     Selenium.WaitElementPresent(StripItemSelector(index));
 }
Exemple #18
0
 public int ItemsCount()
 {
     return((int)(long)Selenium.ExecuteScript("return $('#{0}_sfList option').length".FormatWith(Prefix)));
 }
Exemple #19
0
 public bool HasEntity(int index)
 {
     return(Selenium.IsElementPresent(StripItemSelector(index)));
 }
Exemple #20
0
 public void DoubleClick(int index)
 {
     Select(index);
     Selenium.FindElement(OptionIdLocator(index)).DoubleClick();
 }
Exemple #21
0
        public override int?NewIndex()
        {
            var result = (string)Selenium.ExecuteScript("return $('#{0}_sfItemsContainer li.sf-strip-element').get().map(function(a){{return parseInt(a.id.substr('{0}'.length + 1));}}).join()".FormatWith(Prefix));

            return(string.IsNullOrEmpty(result) ? 0 : result.Split(',').Select(int.Parse).Max() + 1);
        }
Exemple #22
0
 public bool HasDetailEntity()
 {
     return(Selenium.FindElements(DetailsDivSelector.CombineCss(" *")).Any());
 }
Exemple #23
0
        public PopupControl <T> View <T>(int index) where T : ModifiableEntity
        {
            Selenium.FindElement(ViewLocatorIndex(index)).Click();

            return(this.ViewPopup <T>(index));
        }
Exemple #24
0
 public bool HasEntity(int index)
 {
     return(Selenium.IsElementPresent(RepeaterItemSelector(index)));;
 }
Exemple #25
0
 public void Click()
 {
     Selenium.Click(_selector);
 }
Exemple #26
0
 public virtual int HiddenItemsCount()
 {
     return((int)(long)Selenium.ExecuteScript("return $('{0} fieldset.hidden').length".FormatWith(ItemsContainerLocator.CssSelector())));
 }
Exemple #27
0
 public static void StopSelenium()
 {
     Selenium.Stop();
     IsSeleniumStarted = false;
 }
Exemple #28
0
 public override void MoveUp(int index)
 {
     Selenium.FindElement(By.CssSelector("#{0}_{1}_btnUp".FormatWith(Prefix, index))).Click();
 }
Exemple #29
0
        public override object DoRun()
        {
            var query = new LocationHeuristictSearchStrategy(Selenium);

            var result = query.DirectLookup(SearchedTagNames, VisibleTextOfTheButton, NeighbourToLookFrom, Direction, Order, LookForOrthogonalNeighboursOnly, exactMatchOnly: true);

            if (Interpreter?.IsAnalysis == true)
            {
                Console.Out.WriteColoredLine(ConsoleColor.Magenta, _instruction?.ToAnalysisString());
                Console.Out.WriteColoredLine(ConsoleColor.Magenta, $"Main Result: \n\t{result.MainResult}\nAll results:\n\t{string.Join("\n\t", result.AllValidResults)}");
            }

            if (result.Success == false)
            {
                throw new LookupFailureException(result, $"Failed {ToString()}.\nCannot find element {(Order > 0 ? (Order + 1).ToString() : "")}({result.AllValidResults.Count()} results found)");
            }

            switch (Technique)
            {
            case Technique.Show:
                BrowserOverlay
                .HighlightElements((Order + 1).ToString(), Color.GreenYellow, result.MainResult)
                .HighlightElements((Order + 1).ToString(), Color.CadetBlue, result.AllValidResults.Except(new[] { result.AllValidResults.ElementAt(Order) }))
                .ShowUntilNextKeyword("Highlighted element will be Clicked");
                return(new OverlayAnswer(BrowserOverlay.Artifacts, "Highlighting complete."));

            case Technique.Javascript:
                Selenium.WebDriver.Click(result.MainResult.WebElement);
                break;

            case Technique.MouseAndKeyboard:
                Selenium.BringToFront();
                var screenLocation = Selenium.PutElementOnScreen(result.MainResult.WebElement);
                if (Interpreter?.IsAnalysis == true)
                {
                    BrowserOverlay
                    .HighlightElements((Order + 1).ToString(), Color.GreenYellow, result.MainResult)
                    .ShowFor(750, "Highlighted element will be Dragged");
                }
                UserInteropAdapter.PressOnPoint(Selenium.BrowserHandle, screenLocation);


                if (Interpreter.IsAnalysis)
                {
                    var oldPosition = Cursor.Position;

                    var tempPoint = new Point(screenLocation.X, screenLocation.Y);
                    UserBindings.ClientToScreen(Selenium.BrowserHandle, ref tempPoint);
                    Cursor.Position = tempPoint;
                    var steps   = 50m;
                    var xOffset = X / steps;
                    var yOffset = Y / steps;

                    for (int i = 0; i < steps; i++)
                    {
                        Cursor.Position = new Point((int)(tempPoint.X + i * xOffset), (int)(tempPoint.Y + i * yOffset));
                        Thread.Sleep(30);
                    }

                    Cursor.Position = oldPosition;
                }

                screenLocation.X += X;
                screenLocation.Y += Y;
                Thread.Sleep(20);

                UserInteropAdapter.ReleaseOnPoint(Selenium.BrowserHandle, screenLocation);
                Thread.Sleep(50);
                break;
            }

            return(new SuccessAnswer($"Performed {ToString()}"));
        }
Exemple #30
0
 public void Remove()
 {
     WaitChanges(() => Selenium.FindElement(RemoveLocator).Click(), "removing");
 }