本文整理汇总了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() + ")");
}
示例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]);
}
示例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();
}
示例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();
}
示例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();
}
示例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() + ")");
}
示例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());
}
示例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());
}
示例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);
}
}
示例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() + ")");
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
}