本文整理汇总了Java中com.gargoylesoftware.htmlunit.ElementNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java ElementNotFoundException类的具体用法?Java ElementNotFoundException怎么用?Java ElementNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ElementNotFoundException类属于com.gargoylesoftware.htmlunit包,在下文中一共展示了ElementNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void execute(Context context)
{
LoggerFactory.getLogger(SelectDropdown.class).debug("Executing action: " + this);
try
{
HtmlSelect select = context.getXPathProcessor().getSingleElementOfType(Util.getCurrentPage(context), Util.replacePlaceholders(path, context), HtmlSelect.class);
HtmlOption option = select.getOptionByValue(Util.replacePlaceholders(value, context));
select.setSelectedAttribute(option, true);
}
catch(ElementNotFoundException e)
{
throw new RuntimeException("No option found for value " + value);
}
}
示例2: updateResources
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
private void updateResources(HtmlPage page) throws ElementNotFoundException {
try {
NumberFormat fmt = NumberFormat.getNumberInstance(Locale.GERMANY);
final HtmlSpan htmlMetal = page.getHtmlElementById("resources_metal");
resources[METAL] = fmt.parse(htmlMetal.asText()).intValue();
final HtmlSpan htmlCrystal = page.getHtmlElementById("resources_crystal");
resources[CRYSTAL] = fmt.parse(htmlCrystal.asText()).intValue();
final HtmlSpan htmlDeuterium = page.getHtmlElementById("resources_deuterium");
resources[DEUTERIUM] = fmt.parse(htmlDeuterium.asText()).intValue();
final HtmlSpan htmlEnergy = page.getHtmlElementById("resources_energy");
resources[ENERGY] = fmt.parse(htmlEnergy.asText()).intValue();
} catch (ParseException exc) {
}
}
示例3: waitForElement
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
public void waitForElement(WebElement element,int timeOutInSeconds) {
WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
wait.ignoring(NoSuchElementException.class);
wait.ignoring(ElementNotVisibleException.class);
wait.ignoring(StaleElementReferenceException.class);
wait.ignoring(ElementNotFoundException.class);
wait.pollingEvery(250,TimeUnit.MILLISECONDS);
wait.until(elementLocated(element));
}
示例4: getElement
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
public WebElement getElement(final By by, final String elementName) {
WebElement element = null;
try {
element = driver.findElement(by);
} catch (final ElementNotFoundException e) {
TestLogging.errorLogger(elementName +
" is not found with locator - " + by.toString());
throw e;
}
return element;
}
示例5: editThenCancel
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
private void editThenCancel(final String name) throws Exception {
final String flagText = "Should not be saved.";
HtmlPage editPage = clickEditLink(getWikiPage(name));
HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
form.getTextAreaByName("content").setText(flagText);
HtmlPage viewPage = (HtmlPage) form.getButtonByName("unlock").click();
assertFalse(viewPage.asText().contains(flagText));
try {
viewPage.getFormByName(ID_EDIT_FORM);
fail("Should be back to view page, not edit form.");
}
catch (ElementNotFoundException ignore) {
}
assertEquals("Should not be present.", 0,viewPage.getByXPath("id('lockedInfo')").size());
}
示例6: hasErrorMessage
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
protected boolean hasErrorMessage(final HtmlPage page) throws Exception {
try {
return page.getByXPath("id('flash')").size() > 0;
}
catch (ElementNotFoundException e) {
return false;
}
}
示例7: testRenameLinkNotAvailableForNonExistantPages
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
public void testRenameLinkNotAvailableForNonExistantPages() throws Exception {
HtmlPage page = getWikiPage(uniqueWikiPageName("RenameLinkTest"));
try {
page.getAnchorByName("rename");
fail();
}
catch (ElementNotFoundException expected) {
}
}
示例8: testCopyLinkNotAvailableForNonExistantPages
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
public void testCopyLinkNotAvailableForNonExistantPages() throws Exception {
HtmlPage page = getWikiPage(uniqueWikiPageName("CopyLinkTest"));
try {
page.getAnchorByName("copy");
fail();
}
catch (ElementNotFoundException expected) {
}
}
示例9: findUsernameField
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
static private HtmlTextInput findUsernameField(HtmlPage aPage) {
HtmlTextInput result = null;
try {
result = aPage.getElementByName("username");
} catch (ElementNotFoundException e) {
}
return result;
}
示例10: findPasswordField
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
static private HtmlPasswordInput findPasswordField(HtmlPage aPage) {
HtmlPasswordInput result = null;
try {
result = aPage.getElementByName("password");
} catch (ElementNotFoundException e) {
}
return result;
}
示例11: logOut
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
@Before
public void logOut() throws IOException, InterruptedException {
// wait for server to come up
Thread.sleep(2000);
// make sure we are logged out
HtmlPage homePage = webClient.getPage(getBaseUri());
try {
homePage.getAnchorByHref("/logout").click();
}
catch (ElementNotFoundException exc) {
// ignore
}
}
示例12: logOut
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
@Before
public void logOut() throws IOException, InterruptedException {
// wait for server to come up
Thread.sleep(2000);
// make sure we are logged out
HtmlPage homePage = webClient.getPage(getBaseUri());
try {
homePage.getAnchorByHref("/logout").click();
}
catch (ElementNotFoundException exc) {
// ignore
}
}
示例13: updateResource
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
void updateResource(HtmlPage page) throws ElementNotFoundException {
updateResources(page);
update(page, this.building, resourceNames);
}
示例14: updateStation
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
void updateStation(HtmlPage page) throws ElementNotFoundException {
updateResources(page);
update(page, this.building, stationNames);
}
示例15: updateDefense
import com.gargoylesoftware.htmlunit.ElementNotFoundException; //导入依赖的package包/类
void updateDefense(HtmlPage page) throws ElementNotFoundException {
updateResources(page);
update(page, this.shipyard, defenseNames);
}