PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/src/test/java/org/sigmah/endtoend/page/GxtGrid.java

http://sigma-h.googlecode.com/
Java | 50 lines | 36 code | 10 blank | 4 comment | 2 complexity | 4dc8d07497f8b3f9d92677c917e362dc MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.endtoend.page;
 7
 8import org.openqa.selenium.By;
 9import org.openqa.selenium.WebElement;
10import org.sigmah.endtoend.xpath.XPath;
11
12import java.util.List;
13
14import static org.sigmah.endtoend.xpath.XPath.*;
15import static org.sigmah.endtoend.xpath.ext.GxtXPath.gridCell;
16import static org.sigmah.endtoend.xpath.ext.GxtXPath.gridRow;
17import static org.sigmah.endtoend.xpath.ext.HtmlXPath.ofClass;
18import static org.sigmah.endtoend.xpath.ext.HtmlXPath.ofClasses;
19
20public class GxtGrid extends GxtComponent {
21    public GxtGrid(WebElement element) {
22        super(element);
23    }
24
25    public WebElement cell(int row, int col) {
26        return find(
27                gridRow(row),
28                gridCell(col)
29        ).getElement();
30    }
31
32    public int columnIndexFromLabel(String label) {
33        List<WebElement> headers = element.findElements(By.xpath(relative(
34                descendant(XPath.element("td"), ofClasses("x-grid3-header", "x-grid3-cell"))
35        )));
36        for(int i=0;i!=headers.size(); ++i) {
37            String text = headers.get(i).getText().trim();
38            if(text.equalsIgnoreCase(label)) {
39                return i+1;
40            }
41        }
42        throw new AssertionError("Column labeled " + label + " does not exist.");
43    }
44
45
46
47    public GxtComponent editor() {
48        return find(descendant(ofClass("x-grid-editor"), not(ofClass("x-hide-display"))));
49    }
50}