Ejemplo n.º 1
0
        private static bool IsWithinScope(WatiN.Core.Element element, WatiN.Core.Element scope)
        {
            if (scope == null)
                return true;

            var parent = element.Parent;
            while (parent != null)
            {
                if (parent.Equals(scope))
                    return true;

                parent = parent.Parent;
            }
            return false;
        }
        private static bool CheckNthRow(Table table, int n, WatiN.Core.Table displayedTable)
        {
            bool foundRow = false;

            var refExpected = table.Rows[0]["Ref"].Trim();
            var refDisplayed = displayedTable.TableRows[n].TableCells[0].Text.Trim();

            var titleExpected = table.Rows[0]["Title"].Trim();
            var titleDisplayed = displayedTable.TableRows[n].TableCells[1].Text.Trim();

            var descriptionExpected = table.Rows[0]["Description"].Trim();
            var descriptionDisplayed = displayedTable.TableRows[n].TableCells[2].Text.Trim();

            var injuredPersonExpected = table.Rows[0]["Injured Person"].Trim();
            var injuredpersonDisplayed = displayedTable.TableRows[n].TableCells[3].Text.Trim();

            var severityExpected = table.Rows[0]["Severity"].Trim();
            var severityDisplayed = displayedTable.TableRows[n].TableCells[4].Text.Trim();

            var siteExpected = table.Rows[0]["Site"].Trim();
            var siteDisplayed = displayedTable.TableRows[n].TableCells[5].Text.Trim();

            var reportedByExpected = table.Rows[0]["Reported By"].Trim();
            var reportedByDisplayed = displayedTable.TableRows[n].TableCells[6].Text.Trim();

            var dateOfAccidentExpected = table.Rows[0]["Date Of Accident"].Trim();
            var dateOfAccidentDisplayed = displayedTable.TableRows[n].TableCells[8].Text.Trim();

            var dateCreatedExpected = table.Rows[0]["Date Created"].Trim();
            var dateCreatedDisplayed = displayedTable.TableRows[n].TableCells[9].Text.Trim();


            if (refExpected == refDisplayed
                && titleExpected == titleDisplayed
                && descriptionExpected == descriptionDisplayed
                && injuredPersonExpected == injuredpersonDisplayed
                && severityExpected == severityDisplayed
                && siteExpected == siteDisplayed
                && reportedByExpected == reportedByDisplayed
                && dateOfAccidentExpected == dateOfAccidentDisplayed
                && dateCreatedExpected == dateCreatedDisplayed
                )
            {
                foundRow = true;
            }

            return foundRow;
        }
Ejemplo n.º 3
0
 public WatiNWindow(WatiN.Core.Browser browser)
 {
     this.browser = browser;
 }
 public IEnumerable<INativeElement> GetElementsWithQuerySelector(ICssSelector selector, WatiN.Core.DomContainer domContainer)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 internal static WatiN.Core.Element FirstWithinScopeOrDefault(this IEnumerable<WatiN.Core.Element> elements, WatiN.Core.Element scope, Func<WatiN.Core.Element, bool> predicate)
 {
     return elements.FirstOrDefault(e => predicate(e) && IsWithinScope(e, scope));
 }
Ejemplo n.º 6
0
 internal static IEnumerable<WatiN.Core.Element> WithinScope(this IEnumerable<WatiN.Core.Element> elements, WatiN.Core.Element scope)
 {
     return elements.Where(e => IsWithinScope(e, scope));
 }
Ejemplo n.º 7
0
 internal static WatiN.Core.Element FirstWithinScopeOrDefault(this IEnumerable<WatiN.Core.Element> elements, WatiN.Core.Element scope)
 {
     return elements.FirstOrDefault(e => IsWithinScope(e, scope));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieve the identification attribute detail of the element with the following priority:
        /// "id", "name", "value", "alt", "custom", "for", "index", "src", "href", "style", "text", "title", "url"
        /// </summary>
        /// <param name="element">Element</param>
        private static Control GetControlIdentity(WatiN.Core.Element element)
        {
            Control control = new Control();

            if (!String.IsNullOrEmpty(element.Id))
            {
                control.Key = ControlKeyType.id;
                control.Value = element.Id.Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("name")))
            {
                control.Key = ControlKeyType.name;
                control.Value = element.GetAttributeValue("name").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("value")))
            {
                control.Key = ControlKeyType.value;
                control.Value = element.GetAttributeValue("value").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("alt")))
            {
                control.Key = ControlKeyType.alt;
                control.Value = element.GetAttributeValue("alt").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("custom")))
            {
                control.Key = ControlKeyType.custom;
                control.Value = element.GetAttributeValue("custom").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("index")))
            {
                control.Key = ControlKeyType.index;
                control.Value = element.GetAttributeValue("index").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("src")))
            {
                control.Key = ControlKeyType.src;
                control.Value = element.GetAttributeValue("src").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("href")))
            {
                control.Key = ControlKeyType.href;
                control.Value = element.GetAttributeValue("href").Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("style")))
            {
                control.Key = ControlKeyType.style;
                control.Value = element.GetAttributeValue("style").Trim();
            }
            else if (!String.IsNullOrEmpty(element.Text))
            {
                control.Key = ControlKeyType.text;
                control.Value = element.Text.Trim();
            }
            else if (!String.IsNullOrEmpty(element.Title))
            {
                control.Key = ControlKeyType.title;
                control.Value = element.Title.Trim();
            }
            else if (!String.IsNullOrEmpty(element.GetAttributeValue("url")))
            {
                control.Key = ControlKeyType.url;
                control.Value = element.GetAttributeValue("url").Trim();
            }
            else
            {
                control = null;
            }

            return control;
        }
Ejemplo n.º 9
0
 public WatiNBrowser(WatiN.Core.Browser browser)
 {
     this.browser = browser;
 }
Ejemplo n.º 10
0
 private static void AssertColumnValue(WatiN.Core.Table searchResultsTable, string property, int columnIndex)
 {
     Assert.NotNull(searchResultsTable.FindRow(property, columnIndex),
         string.Format("Could not find cell containing '{0}', in column '{1}'", property, columnIndex));
 }
Ejemplo n.º 11
0
 public static WatiN.Core.Element FirstDisplayedOrDefault(this IEnumerable<WatiN.Core.Element> elements, WatiN.Core.Element scope, Func<WatiN.Core.Element, bool> predicate)
 {
     return elements.FirstOrDefault(e => predicate(e) && IsDisplayed(e) && IsWithinScope(e, scope));
 }