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


Java HtmlUnitWebElement类代码示例

本文整理汇总了Java中org.openqa.selenium.htmlunit.HtmlUnitWebElement的典型用法代码示例。如果您正苦于以下问题:Java HtmlUnitWebElement类的具体用法?Java HtmlUnitWebElement怎么用?Java HtmlUnitWebElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: unsetValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * unselect a value
 *
 * @param value the value to unselect
 */
@Override
@PublicAtsApi
public void unsetValue(
                        String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement el : optionElements) {
        if (el.getText().equals(value)) {
            if (el.isSelected()) {
                ((HtmlUnitWebElement) el).click();

                UiEngineUtilities.sleep();
            }
            return;
        }
    }
    throw new SeleniumOperationException("Option with label '" + value + "' not found. ("
                                         + this.toString() + ")");
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:28,代码来源:HiddenHtmlMultiSelectList.java

示例2: getValues

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * @return the selected value
 */
@Override
@PublicAtsApi
public String[] getValues() {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<String> values = new ArrayList<String>();
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement element : optionElements) {
        if (element.isSelected()) {
            values.add(element.getText());
        }
    }
    if (values.isEmpty()) {

        throw new SeleniumOperationException("There is no selected 'option' in " + this.toString());
    }
    return values.toArray(new String[0]);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:24,代码来源:HiddenHtmlMultiSelectList.java

示例3: check

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Check the check box
 */
@Override
@PublicAtsApi
public void check() {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    if (!element.isEnabled()) {
        throw new UnsupportedOperationException("You may not check a disabled element." + toString());
    }
    if (!element.isSelected()) {

        element.click();
    }

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:21,代码来源:HiddenHtmlCheckBox.java

示例4: unCheck

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Uncheck the check box
 */
@Override
@PublicAtsApi
public void unCheck() {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    if (!element.isEnabled()) {
        throw new UnsupportedOperationException("You may not uncheck a disabled element." + toString());
    }
    if (element.isSelected()) {

        element.click();
    }

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:21,代码来源:HiddenHtmlCheckBox.java

示例5: select

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Select radio button
 *
 * @param value of the button to select
 */
@PublicAtsApi
public void select(
                    String value ) {

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this,
                                                                      "[@value='" + value + "']",
                                                                      true);
    if (!element.isEnabled()) {

        throw new UnsupportedOperationException("You may not select a disabled element." + toString());
    }
    element.click();

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:21,代码来源:HiddenHtmlRadioList.java

示例6: setValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * set the single selection value
 *
 * @param value the value to select
 */
@Override
@PublicAtsApi
public void setValue(
                      String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement el : optionElements) {
        if (el.getText().equals(value)) {
            ((HtmlUnitWebElement) el).click();
            UiEngineUtilities.sleep();
            return;
        }
    }

    throw new SeleniumOperationException("Option with label '" + value + "' not found. ("
                                         + this.toString() + ")");
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:26,代码来源:HiddenHtmlSingleSelectList.java

示例7: getValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * @return the single selection value
 */
@Override
@PublicAtsApi
public String getValue() {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement element : optionElements) {
        if (element.isSelected()) {
            return element.getText();
        }
    }
    throw new SeleniumOperationException("There is no selected 'option' in " + this.toString());
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:HiddenHtmlSingleSelectList.java

示例8: getAllPossibleValues

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * @return  a list with all possible selection values
 */
@Override
@PublicAtsApi
public List<String> getAllPossibleValues() {

    List<String> values = new ArrayList<String>();
    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));

    if (optionElements.size() > 0) {
        for (WebElement element : optionElements) {
            values.add(element.getText());
        }
        return values;

    }
    throw new SeleniumOperationException("There is no selectable 'option' in " + this.toString());
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:23,代码来源:HiddenHtmlSingleSelectList.java

示例9: getHtmlUnitElement

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
private HtmlElement getHtmlUnitElement(HtmlUnitWebElement webElement){
    try {
        boolean changed=false;
        Field field = HtmlUnitWebElement.class.getDeclaredField("element");
        if (!field.isAccessible()) {
            
            field.setAccessible(true);
            changed=true;
        }
        
        HtmlElement htmlElement = (HtmlElement)field.get(webElement);
        if(changed)
            field.setAccessible(false);
        return htmlElement;
    } catch (Exception e) {
        throw new Error(e.getMessage(), e);
    }
}
 
开发者ID:jhc-systems,项目名称:redsniff,代码行数:19,代码来源:SeleniumController.java

示例10: setValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * select a value
 *
 * @param value the value to select
 */
@Override
@PublicAtsApi
public void setValue(
                      String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    if (selectElement.getAttribute("multiple") == null) {
        throw new SeleniumOperationException("Not a multi-select. You may only add a selection to a select that supports multiple selections. ("
                                             + this.toString() + ")");
    }

    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement el : optionElements) {
        if (el.getText().equals(value)) {
            if (!el.isSelected()) {
                ((HtmlUnitWebElement) el).click();

                UiEngineUtilities.sleep();
            }
            return;
        }
    }

    throw new SeleniumOperationException("Option with label '" + value + "' not found. ("
                                         + this.toString() + ")");
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:34,代码来源:HiddenHtmlMultiSelectList.java

示例11: setValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Set the Text Area value
 *
 * @param value
 */
@Override
@PublicAtsApi
public void setValue(
                      String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    element.clear();
    element.sendKeys(value);

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:HiddenHtmlTextArea.java

示例12: appendValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Append text to the current content of a Text Area
 * 
 * @param value
 */
@Override
@PublicAtsApi
public void appendValue(
                         String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    element.sendKeys(value);

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:HiddenHtmlTextArea.java

示例13: appendValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Append text to the current content of a Text Box
 * 
 * @param value
 */
@PublicAtsApi
public void appendValue(
                         String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    element.sendKeys(value);

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:17,代码来源:HiddenHtmlTextBox.java

示例14: setValue

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
/**
 * Set the Text Box value
 *
 * @param value
 */
@Override
@PublicAtsApi
public void setValue(
                      String value ) {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    element.clear();
    element.sendKeys(value);

    UiEngineUtilities.sleep();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:HiddenHtmlTextBox.java

示例15: isElementEnabled

import org.openqa.selenium.htmlunit.HtmlUnitWebElement; //导入依赖的package包/类
@Override
@PublicAtsApi
public boolean isElementEnabled() {

    try {
        HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this.element);
        return element.isEnabled();
    } catch (ElementNotFoundException nsee) {
        return false;
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:12,代码来源:HiddenHtmlElementState.java


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