Exemplo n.º 1
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            String xPath = String.Empty;

            if (Parent is ComboBox combo)
            {
                // current is select
                if (!String.IsNullOrEmpty(Text))
                {
                    xPath = $"./option[normalize-space()={Text.XPathText()}]";
                }
                var item = elem.GetElementByXPath(xPath);
                item.Click();
                browser.WaitForComplete();
            }
            else
            {
                // current = selector pane
                if (!String.IsNullOrEmpty(Text))
                {
                    xPath = $"./div[@class='selector-body']/ul[@class='selector-ul']/li[normalize-space()={Text.XPathText()}]";
                }
                var item = elem.GetElementByXPath(xPath);
                item.Click();
                browser.WaitForComplete();
            }
        }
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            ITestElement row = null;

            if (!String.IsNullOrEmpty(Id))
            {
                var id     = Id.ResolveValue(root);
                var script = $"return window.__tests__.$invoke({{target: 'datagrid', testId: '{Parent.TestId}', action: 'selectRow', id: '{id}'}});";
                var result = browser.ExecuteScript(script);
                if (result == null || result != "success")
                {
                    throw new TestException($"Could not select element with id='{id}'");
                }
                WaitClient();

                row = elem.GetElementByXPath(".//tr[contains(@class, 'dg-row') and contains(@class, 'active')]");
            }
            else if (!String.IsNullOrEmpty(Text))
            {
                row = elem.GetElementByXPath($".//tr[contains(@class, 'dg-row')]/td//span[normalize-space()={Text.XPathText()}]/ancestor::tr");

                var cell = row.TryGetElementByXPath("./td[@class='details-marker']");
                if (cell == null)
                {
                    cell = row.TryGetElementByXPath("./td/span[@class='dg-cell']/..");
                }
                if (cell == null)
                {
                    cell = row.TryGetElementByXPath("./td/span[contains(@class, 'span-sum')]/..");
                }
                if (cell == null)
                {
                    throw new TestException("Could not find applicable cell in DataGridRow");
                }
                cell.Click();
                WaitClient();
            }

            if (row == null)
            {
                throw new TestException("DataGridRow. Attributes 'Id' or 'Text' are required");
            }


            foreach (var step in Steps)
            {
                step.ElementRun(root, browser, row);
            }
        }
Exemplo n.º 3
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = String.Empty;

            if (!String.IsNullOrEmpty(Label))
            {
                xPath = $".//div[contains(@class, 'control-group')]/label/span[normalize-space()={Label.XPathText()}]/../../div[contains(@class, 'input-group')]/*";
            }
            else if (!String.IsNullOrEmpty(TestId))
            {
                xPath = $".//div[contains(@class, 'control-group')][@test-id='{TestId}']/div[contains(@class, 'input-group')]/*";
            }

            var scope = control.GetElementByXPath(xPath);

            var tn = scope.TagName;

            if (tn != "input" && tn != "textarea" && tn != "span")
            {
                throw new TestException($"Invalid element '{tn}'. Expected 'input' or 'textarea' or 'span'");
            }

            foreach (var step in Steps)
            {
                step.ElementRun(root, browser, scope);
            }
        }
Exemplo n.º 4
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            var period = control.GetElementByXPath(".//div[@class='nav-global-period']//div[@class='input-group']");

            period.Click();
            WaitClient();
            var menu = period.GetElementByXPath("./div[contains(@class, 'period-pane')]/ul[@class='period-menu']");

            String xPathItem = $"./li/a[normalize-space()={Text.XPathText()}]/..";
            var    menuItem  = menu.GetElementByXPath(xPathItem);
            var    cls       = menuItem.GetAttribute("class");

            if (cls.Contains("active"))
            {
                // already selected
                period.Click();                 // close
                WaitClient();
            }
            else
            {
                menuItem.Click();
                browser.WaitForComplete();
                WaitClient();
            }
        }
Exemplo n.º 5
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = String.Empty;

            if (Text != null)
            {
                xPath = $".//button[contains(@class, 'btn')][normalize-space()={Text.XPathText()}]";
            }
            else if (TestId != null)
            {
                xPath = $".//button[contains(@class, 'btn')][@test-id='{TestId}']";
            }
            else if (Icon != null)
            {
                xPath = $".//button[contains(@class,'btn')]/i[contains(@class, 'ico-{Icon.ToKebabCase()}')]";
            }
            else
            {
                throw new TestException("Button. Attributes 'Text', 'TextId' or 'Icon' are required");
            }

            var scope = control.GetElementByXPath(xPath);

            foreach (var step in Steps)
            {
                step.ElementRun(root, browser, scope);
            }
        }
Exemplo n.º 6
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            ITestElement td;

            if (!String.IsNullOrEmpty(Name))
            {
                String xPath = $".//tr/td[contains(@class, 'prop-name')][normalize-space()={Name.XPathText()}]/../td[contains(@class, 'prop-value')]";
                td = control.GetElementByXPath(xPath);
            }
            else
            {
                String xPath = $".//tr";
                var    rows  = control.GetElementsByXPath(xPath);
                if (Index < 0 || Index >= rows.Count)
                {
                    throw new TestException($"Index was outside the bounds of the array. (Index={Index}, Rows={rows.Count})");
                }
                var row = rows[Index];
                td = row.GetElementByXPath("./td[contains(@class, 'prop-value')]");
            }
            if (td.Text != Value)
            {
                throw new TestException($"Invalid property grid value. Actual:'{td.Text}', expected: '{Value}'");
            }
        }
Exemplo n.º 7
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            if (Text == null)
            {
                throw new TestException("SelectCompany. The Text attribute is required");
            }
            String xPathCompany = $".//div[contains(@class,'a2-company-btn')]";
            var    comp         = control.GetElementByXPath(xPathCompany);
            var    btn          = comp.GetElementByXPath(".//button");

            btn.Click();
            WaitClient();
            String xPathItem = $".//a[contains(@class,'dropdown-item')]//span[contains(@class,'company-menu-name')][normalize-space()={Text.XPathText()}]/..";
            var    menuItem  = comp.GetElementByXPath(xPathItem);

            var icon = menuItem.GetElementByXPath("./i[contains(@class, 'ico')]", checkVisibility: false);
            var cls  = icon.GetAttribute("class");

            if (cls.Contains("ico-check"))
            {
                /*already selected*/
                btn.Click();
                WaitClient();
            }
            else
            {
                menuItem.Click();
                browser.WaitForComplete();
                WaitClient();
            }
        }
Exemplo n.º 8
0
        void ClickCaretButton(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            var xPath = "./../button[contains(@class, 'btn-caret')]";
            var caret = elem.GetElementByXPath(xPath);

            caret.Click();
            WaitClient();
        }
Exemplo n.º 9
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            var body = control.GetElementByXPath($".//{tagName}");

            foreach (var r in Rows)
            {
                r.ElementRun(root, browser, body);
            }
        }
Exemplo n.º 10
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Icon != null)
            {
                xPath = $"./ancestor::div[contains(@class, 'input-group')]//*[contains(@class, 'add-on')]//i[contains(@class, 'ico-{Icon.ToKebabCase()}')]";
            }
            browser.Click(control.GetElementByXPath(xPath));
        }
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Text != null)
            {
                xPath = $".//div[contains(@class,'a2-tab-bar-item')]/a[contains(@class,'a2-tab-button')]/span[contains(@class,'content')][normalize-space()={Text.XPathText()}]";
            }
            browser.Click(control.GetElementByXPath(xPath));
        }
Exemplo n.º 12
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            // current pos - input
            var control   = elem.GetElementByXPath("./ancestor::div[contains(@class, 'control-group')]");
            var elemClass = control.GetAttribute("class");

            if (!elemClass.Contains("invalid"))
            {
                throw new TestException("Element is valid");
            }
            String xPath = String.Empty;

            if (!String.IsNullOrEmpty(Message))
            {
                //elem.GetElementByXPath("./ancestor::div[contains(@class, 'input-group')]/a").GetAttribute("class")
                xPath = $"./ancestor::div[contains(@class, 'input-group')]/div[contains(@class, 'validator')]/span[@class='error' and normalize-space()={Message.XPathText()}]";
            }
            var validator = elem.GetElementByXPath(xPath, checkVisibility: false);
        }
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            // current pos - input (debounce!)
            Thread.Sleep(50);             // Vue
            var pane = elem.GetElementByXPath("./../div[contains(@class, 'selector-pane')]");

            foreach (var s in Steps)
            {
                s.ElementRun(root, browser, pane);
            }
        }
Exemplo n.º 14
0
 public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
 {
     // current pos - input
     switch (Parent)
     {
     case Button btn:
         ClickCaretButton(root, browser, elem);
         return;
     }
     elem.GetElementByXPath("./../a/span[@class='caret']")?.Click();
 }
Exemplo n.º 15
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Text != null)
            {
                xPath = $".//button[contains(@class,'dropdown-item')][normalize-space()={Text.XPathText()}]";
            }
            browser.Click(control.GetElementByXPath(xPath));
            browser.Escape();
        }
Exemplo n.º 16
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            // current pos - input
            var control   = elem.GetElementByXPath("./../..");
            var elemClass = control.GetAttribute("class");

            if (elemClass.Contains("valid"))
            {
                return;
            }
            throw new TestException("Element is not valid");
        }
Exemplo n.º 17
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Header != null)
            {
                xPath = $".//li[contains(@class,'a2-list-item')]//div[contains(@class,'list-item-header')][normalize-space()={Header.XPathText()}]";
            }
            var elem = control.GetElementByXPath(xPath);

            elem.Click();
            browser.WaitForComplete();
        }
Exemplo n.º 18
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            // current = selector pane
            String xPath = String.Empty;

            if (!String.IsNullOrEmpty(Text))
            {
                xPath = $"./div[@class='selector-body']//table//td/span[normalize-space()={Text.XPathText()}]";
            }
            var item = elem.GetElementByXPath(xPath);

            item.Click();
        }
Exemplo n.º 19
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            // control is <input>
            var check = control.GetAttribute("xcheck");

            if (check == null)
            {
                return;                 // already unchecked
            }
            var elem = control.GetElementByXPath("./parent::label");

            elem.Click();
            WaitClient();
        }
Exemplo n.º 20
0
 public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
 {
     if (Parent is Panel panel)
     {
         var cls = control.GetAttribute("class");
         if (cls.Contains("expanded"))
         {
             return;                     // already open
         }
         var header = control.GetElementByXPath(".//div[contains(@class,'panel-header-slot')]");
         header.Click();
         Thread.Sleep(50);                 // Vue
     }
 }
Exemplo n.º 21
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = ".//ul[contains(@class, 'tree-view')]";

            if (TestId != null)
            {
                xPath = $".//ul[contains(@class, 'tree-view')][@test-id='{TestId}']";
            }
            var view = control.GetElementByXPath(xPath);

            foreach (var s in Steps)
            {
                s.ElementRun(root, browser, view);
            }
        }
Exemplo n.º 22
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            var cls = control.GetAttribute("class");

            if (cls.Contains("expanded"))
            {
                return;
            }
            var exp = control.GetElementByXPath(".//a[@class='toggle']");

            exp.Click();
            WaitClient();
            browser.WaitForComplete();
            WaitClient();
        }
Exemplo n.º 23
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = String.Empty;

            if (!String.IsNullOrEmpty(TestId))
            {
                xPath = $".//div[contains(@class, 'data-grid-container')][@test-id='{TestId}']";
            }

            var dataGrid = control.GetElementByXPath(xPath);

            foreach (var step in Steps)
            {
                step.ElementRun(root, browser, dataGrid);
            }
        }
Exemplo n.º 24
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Text != null)
            {
                xPath = $".//li/div[@class='overlay']/a[normalize-space()={Text.XPathText()}]";
            }
            var item = control.GetElementByXPath(xPath);

            item.Click();
            WaitClient();
            var li = item.GetElementByXPath("./../..");

            foreach (var s in Steps)
            {
                s.ElementRun(root, browser, li);
            }
        }
Exemplo n.º 25
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem)
        {
            WaitClient();
            var tagName = elem.TagName;
            var txt     = elem.Text;

            if (tagName == "textarea")
            {
                txt = elem.GetAttribute("value");
            }
            else if (tagName == "select")
            {
                txt = elem.GetElementByXPath("./../div[@class='select-wrapper']")?.Text;
            }
            if (txt != Text)
            {
                throw new TestException($"Text mismatch. Actual: '{txt}', expected: '{Text}'");
            }
        }
Exemplo n.º 26
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Url != null)
            {
                xPath = $".//a[@href='{Url.Trim()}']";
            }
            else if (Text != null)
            {
                xPath = $".//a[normalize-space()={Text.XPathText()}]";
            }
            else if (TestId != null)
            {
                xPath = $".//a[@test-id='{TestId}']";
            }
            var elem = control.GetElementByXPath(xPath);

            elem.Click();
            browser.WaitForComplete();
        }
Exemplo n.º 27
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = null;

            if (Text != null)
            {
                xPath = $".//button[contains(@class,'btn')][normalize-space()={Text.XPathText()}]";
            }
            else if (Icon != null)
            {
                xPath = $".//button[contains(@class,'btn')]/i[contains(@class, 'ico-{Icon.ToKebabCase()}')]";
            }
            else if (TestId != null)
            {
                xPath = $".//button[contains(@class,'btn') and @test-id='{TestId}']";
            }
            else
            {
                throw new TestException("ClickButton. Attributes 'Text' or 'Icon' are required");
            }
            browser.Click(control.GetElementByXPath(xPath));
        }
Exemplo n.º 28
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = String.Empty;

            if (!String.IsNullOrEmpty(Label))
            {
                xPath = $".//label[contains(@class, 'checkbox')][normalize-space()={Label.XPathText()}]/input";
            }
            else if (!String.IsNullOrEmpty(TestId))
            {
                xPath = $".//label[contains(@class, 'checkbox')][@test-id='{TestId}']/input";
            }

            // The <checkbox> is hidden.
            var scope = control.GetElementByXPath(xPath, checkVisibility: false);

            foreach (var step in Steps)
            {
                if (step is ElementStep es)
                {
                    es.ElementRun(root, browser, scope);
                }
            }
        }
Exemplo n.º 29
0
        public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control)
        {
            String xPath = String.Empty;

            if (!String.IsNullOrEmpty(Label))
            {
                xPath = $".//div[contains(@class, 'control-group')]/label/span[normalize-space()={Label.XPathText()}]/../../div[contains(@class, 'input-group')]/select";
            }
            else if (!String.IsNullOrEmpty(TestId))
            {
                xPath = $".//div[contains(@class, 'control-group')][@test-id='{TestId}']/div[contains(@class, 'input-group')]/select";
            }

            // The <select> is hidden. A <select-wrapper> is shown instead.
            var scope = control.GetElementByXPath(xPath, checkVisibility: false);

            scope.Click();
            Thread.Sleep(10);

            foreach (var step in Steps)
            {
                step.ElementRun(root, browser, scope);
            }
        }