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(); } }
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(); } }
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}'"); } }
protected void RunSteps(IRootElement root, IWebBrowser browser, ITestElement control) { foreach (var step in Steps) { step.ElementRun(root, browser, control); } }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem) { var dis = elem.GetAttribute("disabled"); if (dis == null) { elem.Click(); WaitClient(); } var val = elem.Text.ToDate(); if (Today) { if (val != DateTime.Today) { throw new TestException($"Date mismatch. Actual: '{val}', expected: '{DateTime.Today.ToString("dd.MM.yyyy")}'"); } } else if (!String.IsNullOrEmpty(Date)) { if (val != Date.ToDate()) { throw new TestException($"Date mismatch. Actual: '{val}', expected: '{Date}'"); } } }
/// <summary> /// Check the extension name in D365 if it exists, else adds a number at the end until it does not exist /// </summary> /// <param name="d365Object"></param> /// <returns></returns> public static string GetCheckExtensionObjectName(IRootElement d365Object) { string name = d365Object.Name; var metaModelService = Common.CommonUtil.GetModelSaveService(); // Create a class with the same name + _Extension and add it to the project // ClassName int numFound = 0; if (d365Object is ISecurityDuty) { while (metaModelService.GetSecurityDutyExtension(name) != null) { numFound++; name = d365Object.Name + numFound.ToString(); } } else if (d365Object is IClassItem) { while (metaModelService.GetClass(name) != null) { numFound++; name = d365Object.Name + numFound.ToString(); } } return(name); }
public static String ResolveValue(this String text, IRootElement root) { if (root == null) { throw new NullReferenceException(nameof(root)); } if (_findBraces == null) { _findBraces = new Regex("\\[\\[(.+?)\\]\\]", RegexOptions.Compiled); } var ms = _findBraces.Matches(text); if (ms.Count == 0) { return(text); } var sb = new StringBuilder(text); foreach (Match m in ms) { String key = m.Groups[1].Value; String val = root.GetValue(key); sb.Replace(m.Value, val); } return(sb.ToString()); }
public virtual void ElementsRun(IRootElement root, IWebBrowser browser, ITestElement control) { foreach (var step in this) { step.ElementRun(root, browser, control); } }
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 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); } }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { IWindow newWindow = browser.GetLastNewWindow(); try { if (!String.IsNullOrEmpty(Title)) { if (newWindow.Title != Title) { throw new TestException($"Invalid window title. Actual:'{newWindow.Title}', expected: '{Title}'"); } } if (!String.IsNullOrEmpty(Url)) { var resolvedUrl = Url.ResolveValue(root).ToLowerInvariant(); if (newWindow.Url.ToLowerInvariant() != resolvedUrl) { throw new TestException($"Invalid window url. Actual:'{newWindow.Url}', expected: '{resolvedUrl}'"); } } var scope = newWindow.GetElementsByClassName("shell")[0]; Steps.ElementsRun(root, browser, scope); } finally { newWindow.Close(); } }
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); } }
void ClickCaretButton(IRootElement root, IWebBrowser browser, ITestElement elem) { var xPath = "./../button[contains(@class, 'btn-caret')]"; var caret = elem.GetElementByXPath(xPath); caret.Click(); WaitClient(); }
public override void setElementType(IRootElement selectedElement) { if (selectedElement is IMenuItem) { this.iMenuItem = selectedElement as IMenuItem; } //else if (selectedElement is IMenuItemExtension) // this.iMenuItemExtension = selectedElement as IMenuItemExtension; }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { var check = control.GetAttribute("xcheck"); if (check?.ToLowerInvariant() != "true") { throw new TestException("The CheckBox is not checked"); } }
private static MDE.MachineElement Convert(IRootElement re) { var m = Convert <MDE.RootElement>(re); m.AssemblyName = re.AssemblyName; m.RootType = re.RootType; return(m); }
public override void Run(IRootElement root, IWebBrowser browser, IScope scope) { var shell = scope.GetElementsByClassName("shell")[0]; foreach (var st in Steps) { st.ElementRun(root, browser, shell); } }
public MultipleConfigurationFilesTest() { var configurationBuilder = new ConfigurationBuilder <IRootElement>(); configurationBuilder .UseJsonString(configOverride) .UseJsonString(configBasic); ConfigInterface = configurationBuilder.Build(); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { var check = control.GetAttribute("xcheck"); if (check != null) { throw new TestException("The CheckBox is checked"); } }
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); } }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { ITestElement scope = FindScope(control); foreach (var itm in Items) { itm.ElementRun(root, browser, scope); } }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { ITestElement dialog = FindDialog(browser); foreach (var step in Steps) { step.ElementRun(root, browser, dialog); } }
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)); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem) { Thread.Sleep(20); // vue set focus var txt = elem.Text.Trim(); if (!String.IsNullOrEmpty(txt)) { throw new TestException($"Text mismatch. Actual: '{txt}', expected: empty"); } }
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(); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem) { var active = browser.ActiveElement(); if (!active.IsSame(elem)) { elem.Click(); WaitClient(); } elem.TypeText(Text); }
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); } }
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(); }
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"); }
public bool TryGetRootElement(out IRootElement rootElement) { var element = this as IRootElement; if (element != null) { rootElement = element; return true; } if (this.VisualParent != null) { return this.VisualParent.TryGetRootElement(out rootElement); } rootElement = null; return false; }