本文整理汇总了Java中com.gargoylesoftware.htmlunit.html.DomNodeList类的典型用法代码示例。如果您正苦于以下问题:Java DomNodeList类的具体用法?Java DomNodeList怎么用?Java DomNodeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DomNodeList类属于com.gargoylesoftware.htmlunit.html包,在下文中一共展示了DomNodeList类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: roomBooking
import com.gargoylesoftware.htmlunit.html.DomNodeList; //导入依赖的package包/类
public void roomBooking( User user, Meeting meeting ) throws Exception
{
List< String > errorMessages = new ArrayList< String >();
HtmlPage page = navigateToPage( user, BOOKING, true );
logger.debug( "Page loaded" );
HtmlForm form = page.getForms().get( 0 );
HtmlButton button = form.getFirstByXPath( "//*[@id=\"Submit\"]" );
HtmlSelect select = (HtmlSelect)page.getElementById( "ConferenceRooms" );
HtmlOption option = select.getOptionByText( meeting.getRoom() );
select.setSelectedAttribute( option, true );
Date date = meeting.getDate();
if( date != null )
{
HtmlTextInput startDate = form.getFirstByXPath( ".//*[@id='StartDate']" );
DateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy" );
startDate.setAttribute( "value", formatter.format( date ) );
}
HtmlInput inputStartTime = form.getInputByName( "StartTime" );
inputStartTime.setValueAttribute( meeting.getFromTime() );
HtmlInput inputEndTime = form.getInputByName( "EndTime" );
inputEndTime.setValueAttribute( meeting.getToTime() );
HtmlInput inputReason = form.getInputByName( "Title" );
inputReason.type( meeting.getReason() );
List< String > attendeesList = meeting.getAttendees();
if( attendeesList != null && attendeesList.size() > 0 )
{
HtmlSelect attendees = (HtmlSelect)page.getElementById( "AttendeesIds" );
for( String participant : attendeesList )
{
attendees.getOptionByText( participant ).setSelected( true );
}
}
logger.debug( "Page filled, clicking button" );
HtmlPage nextPage = button.click();
String pageUrl = new StringBuilder( "http://" ).append( WEBSITE ).append( SHOW_MY_BOOKINGS ).toString();
if( !nextPage.getBaseURI().equals( pageUrl ) )
{
errorMessages.add( "Room already booked" );
logger.error( errorMessages );
throw new InvalidInputException( errorMessages );
}
// Error check
DomNodeList< DomElement > list = page.getElementsByTagName( "span" );
for( DomElement domElement : list )
{
if( domElement.getAttribute( "class" ).contains( "field-validation-error" ) )
{
errorMessages.add( domElement.getTextContent() );
}
}
if( errorMessages.size() > 0 )
{
logger.error( errorMessages );
throw new InvalidInputException( errorMessages );
}
}
开发者ID:Vedang18,项目名称:ProBOT,代码行数:68,代码来源:Bookie.java
示例2: testEntries
import com.gargoylesoftware.htmlunit.html.DomNodeList; //导入依赖的package包/类
/**
* Tests that all menu entries point to an existing page.
*
* @throws IOException In case of I/O error.
*/
@Test
public void testEntries() throws IOException {
HtmlPage page = getWebClient().getPage("http://localhost/");
HtmlNav menu = page.<HtmlNav> getHtmlElementById("main-menu");
DomNodeList<HtmlElement> anchors = menu.getElementsByTagName("a");
for (HtmlElement anchor : anchors) {
LOGGER.debug("Testing {}", ((HtmlAnchor) anchor).getHrefAttribute());
HtmlPage newPage = (HtmlPage) anchor.click();
assertThat(newPage.getWebResponse().getStatusCode()).isEqualTo(HttpStatus.OK.value());
}
}
开发者ID:The4thLaw,项目名称:demyo,代码行数:19,代码来源:MenuIT.java
示例3: getNextPageUrl
import com.gargoylesoftware.htmlunit.html.DomNodeList; //导入依赖的package包/类
/**
* 根据提供的HtmlPage寻找上一页的URL
* @param page
* @return
*/
private String getNextPageUrl(HtmlPage page) {
DomNodeList<DomElement> thElement = page.getElementsByTagName("th");
for (DomElement element: thElement) {
if ("foot".equals(element.getAttribute("class"))) {
DomNodeList<HtmlElement> aElement = element.getElementsByTagName("a");
for (HtmlElement tempElement: aElement) {
if ("上页".equals(tempElement.getTextContent())) {
return tempElement.getAttribute("href");
}
}
}
}
return null;
}
开发者ID:xianlubird,项目名称:PkuIntern,代码行数:20,代码来源:PkuFetch.java
示例4: main
import com.gargoylesoftware.htmlunit.html.DomNodeList; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://www.gnu.org/home.es.html");
DomNodeList<DomElement> nodeList = page.getElementsByTagName("a");
for (DomElement element : nodeList){
System.out.println(element.getTextContent()+ " -> " +element.getAttribute("href"));
}
}
开发者ID:chuidiang,项目名称:chuidiang-ejemplos,代码行数:11,代码来源:ExtractingLinksWithHtmlUnit.java
示例5: getElementsByTagName
import com.gargoylesoftware.htmlunit.html.DomNodeList; //导入依赖的package包/类
public DomNodeList<DomElement> getElementsByTagName(String tagName){
return this.Page.getElementsByTagName(tagName);
}
开发者ID:klevinism,项目名称:Ads-Attacher,代码行数:4,代码来源:WebPageManipulation.java
注:本文中的com.gargoylesoftware.htmlunit.html.DomNodeList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论