Ejemplo n.º 1
0
        protected new void TestFindCells()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            IList <TableCell> cells = table.FindCells("1=Green", "0");

            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual("Watermelon", cells[0].Element.Text);
            Assert.AreEqual("Kiwi", cells[1].Element.Text);

            cells = table.FindCells(@"0=Orange|1=Red", 4);
            Assert.IsNotNull(cells);
            Assert.AreEqual(4, cells.Count);
            Assert.AreEqual("5.0", cells[0].Element.Text);
            Assert.AreEqual("6.7", cells[1].Element.Text);
            Assert.AreEqual("3.2", cells[2].Element.Text);
            Assert.AreEqual("7.7", cells[3].Element.Text);

            cells = table.FindCells("3=Maybe", "0");
            Assert.IsNotNull(cells);
            Assert.IsFalse(cells.Any());

            cells = table.FindCells(@"\9=Fluffy", 2);
            Assert.IsNotNull(cells);
            Assert.IsFalse(cells.Any());

            cells = table.FindCells(@"2=Large", 42);
            Assert.IsNotNull(cells);
            Assert.IsFalse(cells.Any());

            bool exceptionThrown = false;

            try
            {
                cells = table.FindCells("11=50%", 1);
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of '11'."));
                Assert.AreEqual("fieldCondition", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                cells = table.FindCells(@"\2=Medium", "23");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of '23'."));
                Assert.AreEqual("columnHeaderText", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 2
0
        protected void TestTableCellProperties()
        {
            TableSamples.GoToTestPage(this.Driver);
            TableCell cell = this.GetTestTableCell();

            Assert.AreEqual(5, cell.RowIndex);
            Assert.AreEqual(1, cell.ColumnIndex);
            Assert.AreEqual("td", cell.Element.TagName);
            Assert.AreEqual("Blue", cell.Element.Text);
        }
Ejemplo n.º 3
0
        protected void TestTableRowProperties()
        {
            TableSamples.GoToTestPage(this.Driver);
            TableRow row = this.GetTestTableRow();

            Assert.AreEqual(10, row.RowIndex);
            Assert.AreEqual(5, row.CellCount);
            Assert.AreEqual("tr", row.Element.TagName);
            Assert.AreEqual("10", row.Element.GetAttribute("name"));
        }
Ejemplo n.º 4
0
        protected new void TestTableProperties(string tableId)
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            Assert.AreEqual(5, table.ColumnCount);
            Assert.AreEqual(12, table.RowCount);
            Assert.AreEqual("table", table.Element.TagName);
            Assert.AreEqual(tableId, table.Element.GetAttribute("id"));
            Assert.IsNull(table.HeaderRow);
            Assert.AreEqual(5, table.HeaderElements.Count);
        }
Ejemplo n.º 5
0
        protected void TestNotEqualInRowQuery()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            IList <TableRow> rows = table.FindRows("Citrus?!=No");

            Assert.IsNotNull(rows);
            Assert.AreEqual(3, rows.Count);
            Assert.AreEqual("1", rows[0].Element.GetAttribute("name"));
            Assert.AreEqual("2", rows[1].Element.GetAttribute("name"));
            Assert.AreEqual("4", rows[2].Element.GetAttribute("name"));
        }
Ejemplo n.º 6
0
        protected void TestGetHeader()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            IWebElement header = table.GetHeader("Size");

            Assert.IsNotNull(header);
            Assert.AreEqual("Size", header.Text);

            header = table.GetHeader(0);
            Assert.IsNotNull(header);
            Assert.AreEqual("Name", header.Text);

            bool exceptionThrown = false;

            try
            {
                header = table.GetHeader("Quantity");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of 'Quantity'."));
                Assert.AreEqual("headerText", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                header = table.GetHeader(8);
            }
            catch (NoSuchElementException)
            {
                if (table.HeaderRow == null)
                {
                    throw;
                }
                exceptionThrown = true;
            }
            catch (ArgumentOutOfRangeException)
            {
                if (table.HeaderElements == null)
                {
                    throw;
                }
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 7
0
        protected void TestGetRows()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            IList <TableRow> rows = table.GetRows();

            Assert.IsNotNull(rows);
            Assert.AreEqual(12, rows.Count);
            for (int i = 0; i < 12; i++)
            {
                Assert.AreEqual(i.ToString(), rows[i].Element.GetAttribute("name"));
            }
        }
Ejemplo n.º 8
0
        protected void TestGetCells()
        {
            TableSamples.GoToTestPage(this.Driver);
            TableRow row = this.GetTestTableRow();

            IList <TableCell> cells = row.GetCells();

            Assert.IsNotNull(cells);
            Assert.AreEqual(5, cells.Count);
            Assert.AreEqual("Mangosteen", cells[0].Element.Text);
            Assert.AreEqual("Dark Red", cells[1].Element.Text);
            Assert.AreEqual("Medium", cells[2].Element.Text);
            Assert.AreEqual("No", cells[3].Element.Text);
            Assert.AreEqual("11.0", cells[4].Element.Text);
        }
Ejemplo n.º 9
0
        protected void TestContainsInRowQuery()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            IList <TableCell> cells = table.FindCells("Name*=Grape", "Rating");

            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual("2.8", cells[0].Element.Text);
            Assert.AreEqual("7.8", cells[1].Element.Text);

            cells = table.FindCells("Color*=l", "Name");
            Assert.IsNotNull(cells);
            Assert.AreEqual(5, cells.Count);
            Assert.AreEqual("Grapefruit", cells[0].Element.Text);
            Assert.AreEqual("Grape", cells[1].Element.Text);
            Assert.AreEqual("Pineapple", cells[2].Element.Text);
            Assert.AreEqual("Blueberry", cells[3].Element.Text);
            Assert.AreEqual("Mango", cells[4].Element.Text);

            cells = table.FindCells("Name*=berry", "Color");
            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual("Blue", cells[0].Element.Text);
            Assert.AreEqual("Red", cells[1].Element.Text);

            bool exceptionThrown = false;

            try
            {
                table.FindCell("Name*=q", "Name");
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);

            cells = table.FindCells("Name*=Snapple", "Citrus?");
            Assert.IsNotNull(cells);
            Assert.AreEqual(0, cells.Count);
        }
Ejemplo n.º 10
0
        protected void TestFindRows()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            IList <TableRow> rows = table.FindRows("Citrus?=Yes");

            Assert.IsNotNull(rows);
            Assert.AreEqual(3, rows.Count);
            Assert.AreEqual("1", rows[0].Element.GetAttribute("name"));
            Assert.AreEqual("2", rows[1].Element.GetAttribute("name"));
            Assert.AreEqual("4", rows[2].Element.GetAttribute("name"));

            rows = table.FindRows(@"Name=Mango|Color=Red&Size=Small|\4=5.0");
            Assert.IsNotNull(rows);
            Assert.AreEqual(4, rows.Count);
            Assert.AreEqual("0", rows[0].Element.GetAttribute("name"));
            Assert.AreEqual("6", rows[1].Element.GetAttribute("name"));
            Assert.AreEqual("9", rows[2].Element.GetAttribute("name"));
            Assert.AreEqual("11", rows[3].Element.GetAttribute("name"));

            rows = table.FindRows("Color=Purple&Size=Large");
            Assert.IsNotNull(rows);
            Assert.IsFalse(rows.Any());

            rows = table.FindRows(@"\13=Fred");
            Assert.IsNotNull(rows);
            Assert.IsFalse(rows.Any());

            bool exceptionThrown = false;

            try
            {
                rows = table.FindRows("Proximity=Near");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of 'Proximity'."));
                Assert.AreEqual("fieldCondition", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 11
0
        protected new void TestFindCell()
        {
            TableSamples.GoToTestPage(this.Driver);
            TableRow row = this.GetTestTableRow();

            TableCell cell = row.FindCell("2");

            Assert.IsNotNull(cell);
            Assert.AreEqual("Medium", cell.Element.Text);

            cell = row.FindCell(1);
            Assert.IsNotNull(cell);
            Assert.AreEqual("Dark Red", cell.Element.Text);

            bool exceptionThrown = false;

            try
            {
                cell = row.FindCell("8");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of '8'."));
                Assert.AreEqual("columnHeaderText", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                cell = row.FindCell(5);
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 12
0
        protected void TestFindRow()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            TableRow row = table.FindRow("Name=Grape");

            Assert.IsNotNull(row);
            Assert.AreEqual("3", row.Element.GetAttribute("name"));

            row = table.FindRow("Size=Large");
            Assert.IsNotNull(row);
            Assert.AreEqual("4", row.Element.GetAttribute("name"));

            row = table.FindRow(@"\4=6.3");
            Assert.IsNotNull(row);
            Assert.AreEqual("5", row.Element.GetAttribute("name"));

            row = table.FindRow(8);
            Assert.IsNotNull(row);
            Assert.AreEqual("8", row.Element.GetAttribute("name"));

            bool exceptionThrown = false;

            try
            {
                row = table.FindRow("Name=Lemon");
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                row = table.FindRow(12);
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                row = table.FindRow("Style=Fancy");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of 'Style'."));
                Assert.AreEqual("fieldCondition", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                row = table.FindRow(@"\8=32");
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 13
0
        protected void TestFindCell()
        {
            TableSamples.GoToTestPage(this.Driver);
            Table table = this.GetTestTable();

            TableCell cell = table.FindCell("Name=Watermelon", "Size");

            Assert.IsNotNull(cell);
            Assert.AreEqual("Large", cell.Element.Text);

            cell = table.FindCell(@"\2=Small", 0);
            Assert.IsNotNull(cell);
            Assert.AreEqual("Grape", cell.Element.Text);

            cell = table.FindCell(10, "Name");
            Assert.IsNotNull(cell);
            Assert.AreEqual("Mangosteen", cell.Element.Text);

            cell = table.FindCell(8, 4);
            Assert.IsNotNull(cell);
            Assert.AreEqual("4.7", cell.Element.Text);

            bool exceptionThrown = false;

            try
            {
                cell = table.FindCell("Name=Mulberry", "Rating");
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                cell = table.FindCell(@"\6=Zesty", "Rating");
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                cell = table.FindCell("Fame=Obscure", "Rating");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of 'Fame'."));
                Assert.AreEqual("fieldCondition", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                cell = table.FindCell("Name=Apple", "Weight");
            }
            catch (ArgumentException ex)
            {
                exceptionThrown = true;
                Assert.IsTrue(ex.Message.StartsWith("The table does not contain a column with the header caption of 'Weight'."));
                Assert.AreEqual("columnHeaderText", ex.ParamName);
            }
            Assert.IsTrue(exceptionThrown);

            exceptionThrown = false;
            try
            {
                cell = table.FindCell(7, 9);
            }
            catch (NoSuchElementException)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);
        }