当前位置: 首页>>代码示例>>Java>>正文


Java WebElement.findElement方法代码示例

本文整理汇总了Java中org.openqa.selenium.WebElement.findElement方法的典型用法代码示例。如果您正苦于以下问题:Java WebElement.findElement方法的具体用法?Java WebElement.findElement怎么用?Java WebElement.findElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.WebElement的用法示例。


在下文中一共展示了WebElement.findElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: editANodeWithEditor

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void editANodeWithEditor() throws Throwable {
    System.err.println("Ignore the following NPE. The DynamicTree class has a bug");
    WebElement tree = page.getTree();
    tree.click();
    final WebElement root = tree.findElement(By.cssSelector(".::root"));
    AssertJUnit.assertEquals("Root Node", root.getText());
    WebElement editor = root.findElement(By.cssSelector(".::editor"));
    editor.clear();
    editor.sendKeys("Hello World", Keys.ENTER);
    root.submit();
    new WebDriverWait(driver, 3).until(new Function<WebDriver, Boolean>() {
        @Override public Boolean apply(WebDriver input) {
            return root.getText().equals("Hello World");
        }
    });
    AssertJUnit.assertEquals("Hello World", root.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:JTreeDynamicTreeTest.java

示例2: reActivateItem

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Step("Rreactivate the item")
public boolean reActivateItem(String itemName){
    WebElement todoItem = driver.findElement(By.xpath("//label[.='" + itemName + "']"));
    WebElement divClass = todoItem.findElement(By.xpath(".."));
    WebElement chkComplete = divClass.findElement(By.tagName("input"));
    chkComplete.click();
    WebElement liClass = null;
    try{
        liClass = divClass.findElement(By.xpath(".//*[@id='clear-completed']"));
        if (liClass.isDisplayed()){
            return false;
        }
    }catch (Exception e){
    }
    return true;
}
 
开发者ID:AdyKalra,项目名称:ToDoMVCEmberJS,代码行数:17,代码来源:BasicTodoMvcPage.java

示例3: expandTree

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void expandTree() throws Throwable {
    WebElement tree = page.getTree();
    tree.click();
    WebElement root = tree.findElement(By.cssSelector(".::nth-node(1)"));
    AssertJUnit.assertEquals("false", root.getAttribute("expanded"));
    AssertJUnit.assertEquals(1 + "", tree.getAttribute("rowCount"));
    new Actions(driver).doubleClick(root).perform();
    new WebDriverWait(driver, 3).until(hasAttributeValue(root, "expanded", "true"));
    AssertJUnit.assertEquals("true", root.getAttribute("expanded"));
    AssertJUnit.assertEquals(3 + "", tree.getAttribute("rowCount"));
    WebElement node1 = tree.findElement(By.cssSelector(".::nth-node(2)"));
    AssertJUnit.assertEquals("Parent 1", node1.getText());
    new Actions(driver).doubleClick(node1).perform();
    WebElement node2 = tree.findElement(By.cssSelector(".::nth-node(3)"));
    AssertJUnit.assertEquals("Child 1", node2.getText());
    WebElement node3 = tree.findElement(By.cssSelector(".::nth-node(4)"));
    AssertJUnit.assertEquals("Child 2", node3.getText());
    WebElement node4 = tree.findElement(By.cssSelector(".::nth-node(5)"));
    AssertJUnit.assertEquals("Parent 2", node4.getText());
    new Actions(driver).doubleClick(node4).perform();
    WebElement node5 = tree.findElement(By.cssSelector(".::nth-node(6)"));
    AssertJUnit.assertEquals("Child 1", node5.getText());
    WebElement node6 = tree.findElement(By.cssSelector(".::nth-node(7)"));
    AssertJUnit.assertEquals("Child 2", node6.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:JTreeDynamicTreeTest.java

示例4: findElementsByCSSWithSelfSelector

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void findElementsByCSSWithSelfSelector() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element1 = driver.findElement(By.name("text-field"));
    WebElement element2 = element1.findElement(By.cssSelector("."));
    AssertJUnit.assertEquals(element1, element2);
    WebElement element3 = element1.findElement(By.cssSelector(".:enabled"));
    AssertJUnit.assertEquals(element1, element3);
    WebElement element4 = element1.findElement(By.cssSelector(".#text-field"));
    AssertJUnit.assertEquals(element1, element4);
    List<WebElement> none = element1.findElements(By.cssSelector(".#text-fieldx"));
    AssertJUnit.assertEquals(0, none.size());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:JavaDriverTest.java

示例5: inTableClickOnIdentityInRowsWithParameters

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Override
public void inTableClickOnIdentityInRowsWithParameters(By elementIdentity, ExamplesTable params) {
    List<WebElement> matchedRows = getMatchedRows(params);
    if (matchedRows.isEmpty()) {
        throw new AssertionError("You should define at list one existing " +
                "record value");
    }
    for (WebElement matchedRow : matchedRows) {
        WebElement elementToClick = matchedRow.findElement
                (elementIdentity);
        webPage.clickOn(elementToClick);
    }
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:14,代码来源:BaseTableSteps.java

示例6: getTableRowByColumnText

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * Example: getRowTextsByColumnText(table, 2, '22') returns row {11, 22, 33}
    * 1	2	3
    * 11	22	33
    * 111	222	333
 * 
 * @param table
 * @param columnIndex Start from 1
 * @param searchText
 * @return
 */
public static final List<String> getTableRowByColumnText(WebElement table, int columnIndex, String searchText) {
	if (!table.getTagName().equalsIgnoreCase("table")) {
   		throw new IllegalArgumentException("Table web element is required");
   	}

	WebElement rowElement = table.findElement(By.xpath("//tr//td[position()=" + columnIndex + " and contains(*|text(), '" + searchText + "')]/.."));
   	List<WebElement> elements = rowElement.findElements(By.tagName("td"));
   	List<String> result = new ArrayList<String>(elements.size());
   	for (WebElement e : elements) {
   		result.add(StringUtils.trim(e.getText()));
   	}
   	return result;
}
 
开发者ID:21ca,项目名称:selenium-testng-template,代码行数:25,代码来源:SeleniumUtils.java

示例7: getNodesByRow

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void getNodesByRow() throws Throwable {
    WebElement tree = page.getTree();
    tree.click();
    WebElement root = tree.findElement(By.cssSelector(".::nth-node(1)"));
    AssertJUnit.assertEquals(1 + "", tree.getAttribute("rowCount"));
    new Actions(driver).doubleClick(root).perform();
    new WebDriverWait(driver, 3).until(hasAttributeValue(tree, "rowCount", 3 + ""));
    AssertJUnit.assertEquals(3 + "", tree.getAttribute("rowCount"));
    WebElement node1 = tree.findElement(By.cssSelector(".::nth-node(2)"));
    AssertJUnit.assertEquals("Parent 1", node1.getText());
    WebElement node2 = tree.findElement(By.cssSelector(".::nth-node(3)"));
    AssertJUnit.assertEquals("Parent 2", node2.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JTreeDynamicTreeTest.java

示例8: nodeEditor

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void nodeEditor() throws Throwable {
    System.err.println("Ignore the following NPE. The DynamicTree class has a bug");
    WebElement tree = page.getTree();
    tree.click();
    WebElement root = tree.findElement(By.cssSelector(".::nth-node(1)"));
    AssertJUnit.assertEquals("Root Node", root.getText());
    WebElement editor = root.findElement(By.cssSelector(".::editor"));
    editor.clear();
    editor.sendKeys("Hello World", Keys.ENTER);
    root.submit();
    AssertJUnit.assertEquals("Hello World", root.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:JTreeDynamicTreeTest.java

示例9: findElementOfElement

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void findElementOfElement() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element = driver.findElement(By.name("box-panel"));
    AssertJUnit.assertNotNull(element);
    WebElement clickMe = element.findElement(By.name("click-me"));
    AssertJUnit.assertNotNull(clickMe);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaDriverTest.java

示例10: clickLink

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * Clicks the specified link found by locating the starting text then following the relative XPath expression.
 * @param startTag          The tag containing the starting text
 * @param startText         The starting text
 * @param relativeXPath     The relative XPath expression
 */
public void clickLink(String startTag, String startText, String relativeXPath) {
    WebElement startingTextElement = webDriver.findElement(
            By.xpath("//" + startTag.toLowerCase() + "[contains(text(),'" + startText + "')]"));
    WebElement link = startingTextElement.findElement(By.xpath(relativeXPath + ".//a"));
    clickAndWaitForPageLoad(link);
}
 
开发者ID:dvsa,项目名称:mot-automated-testsuite,代码行数:13,代码来源:WebDriverWrapper.java

示例11: getCellEditorCombobox

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void getCellEditorCombobox() throws Throwable {
    driver = new JavaDriver();
    WebElement comboCell = driver.findElement(By.cssSelector("table::mnth-cell(1,3)"));
    AssertJUnit.assertEquals("Snowboarding", comboCell.getText());
    WebElement comboCellEditor = driver.findElement(By.cssSelector("table::mnth-cell(1,3)::editor"));
    AssertJUnit.assertEquals("combo-box", comboCellEditor.getTagName());
    WebElement option = comboCellEditor.findElement(By.cssSelector(".::all-options[text='Knitting']"));
    // Needs the click to put in editing mode
    // comboCell.click();
    option.click();
    AssertJUnit.assertEquals("Knitting", comboCell.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:JTableRenderTest.java

示例12: clickOnCol

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
private void clickOnCol(WebElement table, int colNum) {
    // Index on the element is 1 based and index on the JTable is 0 based.
    // Hence adding 1 to the colNum
    WebElement col = table.findElement(By.cssSelector(".::mnth-cell(1," + (colNum + 1) + ")"));
    col.click();
    table.sendKeys(Keys.NULL);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JTableColumnSelectionTest.java

示例13: clickOnRow

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
private void clickOnRow(WebElement table, int rowNum) {
    // Index on the element is 1 based and index on the JTable is 0 based.
    // Hence adding 1 to the rowNum
    WebElement row = table.findElement(By.cssSelector(".::mnth-cell(" + (rowNum + 1) + ",3)"));
    row.click();
    table.sendKeys(Keys.NULL);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JTableRowSelectionTest.java

示例14: getLeftRightComponents

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void getLeftRightComponents() throws Throwable {
    driver = new JavaDriver();
    WebElement splitPaneLeft = driver.findElement(By.cssSelector("split-pane::left"));
    splitPaneLeft.findElement(By.cssSelector("list"));
    WebElement splitPaneTop = driver.findElement(By.cssSelector("split-pane::top"));
    AssertJUnit.assertEquals(splitPaneTop, splitPaneLeft);
    WebElement splitPaneRight = driver.findElement(By.cssSelector("split-pane::right"));
    WebElement splitPaneBottom = driver.findElement(By.cssSelector("split-pane::bottom"));
    AssertJUnit.assertEquals(splitPaneBottom, splitPaneRight);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:JSplitPaneTest.java

示例15: initUnit1ModificationById

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
private void initUnit1ModificationById(int id) {
    WebElement checkbox = driver.findElement(By.cssSelector(String.format("input[value='%s']", id)));
    WebElement row = checkbox.findElement(By.xpath("./../.."));
    List<WebElement> cells = row.findElements(By.tagName("td"));
    cells.get(7).findElement(By.tagName("a")).click();
}
 
开发者ID:SpaceHead1C,项目名称:module-template,代码行数:7,代码来源:Unit1Helper.java


注:本文中的org.openqa.selenium.WebElement.findElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。