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


Java HtmlAnchor.click方法代码示例

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


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

示例1: searchHouse

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
public void searchHouse() throws Exception {
	String url = "http://wx.fang.anjuke.com/loupan/?pi=baidu-cpcaf-wx-tyong2&utm_source=baidu&utm_medium=cpc&kwid=3367579001&utm_term=%E6%97%A0%E9%94%A1%E6%88%BF%E4%BA%A7%E7%BD%91";
	HtmlAnchor link = null;
	HtmlPage page = webClient.getPage(url);  
	
	//System.out.println(webClient.getCookies(new URL(url)));
	//System.out.println(page.asXml());
	List<HtmlAnchor> anchors = page.getAnchors();
	for(HtmlAnchor ha : anchors) {
		//System.out.println(ha.asXml());
		if(ha.asXml().indexOf("下一页") != -1) {
			link = ha;
			break;
		}
	}
	
	HtmlPage next = link.click();
	System.out.println(next.asXml());
}
 
开发者ID:knshen,项目名称:JSearcher,代码行数:20,代码来源:PostDemo.java

示例2: execute

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void execute(Context context)
{
	LoggerFactory.getLogger(OpenLink.class).debug("Executing action: " + this);
	HtmlAnchor element = context.getXPathProcessor().getSingleElementOfType(Util.getCurrentPage(context), Util.replacePlaceholders(path, context), HtmlAnchor.class);

	try
	{
		element.click();
	}
	catch(IOException e)
	{
		throw new RuntimeException(e);
	}
}
 
开发者ID:sropelato,项目名称:Fetchino,代码行数:19,代码来源:OpenLink.java

示例3: getCallbackUrl

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Override
protected String getCallbackUrl(HtmlPage authorizationPage) throws Exception {

    HtmlInlineFrame frame = (HtmlInlineFrame) authorizationPage.getElementById("ptlogin_iframe");
    // log.info("------------------------###\n{}------------------------===\n", authorizationPage.asXml());
    HtmlPage loginPage = (HtmlPage) frame.getEnclosedPage();

    log.info("------------------------###\n{}------------------------===\n", loginPage.getUrl().toString());

    HtmlAnchor passwordLogin = (HtmlAnchor) loginPage.getElementById("switcher_plogin");
    passwordLogin.click();

    HtmlForm loginForm = loginPage.getFormByName("loginform");
    loginForm.getInputByName("u").setValueAttribute(USER_QQ);
    loginForm.getInputByName("p").setValueAttribute(USER_PASSWORD);
    HtmlSubmitInput button = (HtmlSubmitInput) loginPage.getElementById("login_button");
    HtmlPage page2 = button.click();
    page2 = button.click();
    log.info(
            "------------------------###\n callbackUrl : {}------------------------===\n{}[email protected]@@@\n",
            page2.getUrl().toString(), page2.asXml());
    return page2.getUrl().toString();
}
 
开发者ID:btpka3,项目名称:pac4j-oauth-tencent,代码行数:24,代码来源:TestTencentClient.java

示例4: searchInBaidu

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
public void searchInBaidu() throws Exception {
	HtmlPage page = webClient.getPage("https://www.baidu.com/");  
	HtmlForm form = page.getFormByName("f");
	
	HtmlTextInput input = form.getInputByName("wd");	
	HtmlSubmitInput button = form.getInputByValue("百度一下");  
	
	input.setValueAttribute("无锡");
	HtmlPage nextPage = button.click();  
	
	//System.out.println(nextPage.asXml());
	
	// hit next page
	HtmlAnchor next = null;
	List list = nextPage.getByXPath("//a");
	for(Object obj : list) {
		if(obj instanceof HtmlAnchor) {
			HtmlAnchor ha = (HtmlAnchor)obj;
			//System.out.println(ha.getTextContent());
			if(ha.getTextContent().indexOf("百度百科") != -1) {
				next = ha;
				break;
			}
		}
	}
	
	
	System.out.println(next.asXml());
	System.out.println("--------------------------");
	HtmlPage p = next.click();
	System.out.println(p.asXml());
	
}
 
开发者ID:knshen,项目名称:JSearcher,代码行数:34,代码来源:PostDemo.java

示例5: shouldOwnerIndexPageNavigateToOwnerDetailPage

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Test
public void shouldOwnerIndexPageNavigateToOwnerDetailPage() throws Exception {
  HtmlPage ownerIndexPage = getPage("/owners");
  List viewEditDeleteButtons = ownerIndexPage.getByXPath("//tbody/tr[1]/td[6]//a");
  HtmlAnchor aHref = (HtmlAnchor) viewEditDeleteButtons.get(0);
  HtmlPage viewOwnerPage = aHref.click();
  assertTrue(viewOwnerPage.getUrl().toString().matches(".*/owners/1$"));
}
 
开发者ID:puncha,项目名称:petclinic,代码行数:9,代码来源:OwnerControllerTests.java

示例6: testHtmlUnit

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Test
public void testHtmlUnit() throws Exception {
    HtmlPage homepage = webClient.getPage("http://localhost/");
    Assert.assertEquals("home" , homepage.getTitleText());

    HtmlAnchor form = homepage.getHtmlElementById("homeLink");
    HtmlPage newPage = form.click();
    Assert.assertEquals("home" , newPage.getTitleText());
}
 
开发者ID:victorbuckservices,项目名称:workshop-spring-4.0-to-4.2,代码行数:10,代码来源:HtmlUnitTest.java

示例7: renamePage

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
protected HtmlPage renamePage(final String pageFrom, final String pageTo) throws IOException {
  HtmlPage page = getWikiPage(pageFrom);
  HtmlAnchor renameAnchor = page.getAnchorByName("rename");
  page = (HtmlPage) renameAnchor.click();
  final HtmlForm form = page.getFormByName("renameForm");
  final HtmlInput input = form.getInputByName("toPage");
  input.setValueAttribute(pageTo);
  page = (HtmlPage) (form.getButtonByName("rename")).click();
  assertEquals(1, page.getByXPath("id('wiki-rendering')").size());
  return page;
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:12,代码来源:WebTestSupport.java

示例8: getAttachmentAtEndOfLink

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
public static String getAttachmentAtEndOfLink(final HtmlAnchor link) throws IOException {
  UnexpectedPage attachment = (UnexpectedPage) link.click();
  BufferedReader in = new BufferedReader(new InputStreamReader(attachment.getInputStream()));
  try {
    return IOUtils.toString(in).trim();
  }
  finally {
    in.close();
  }
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:11,代码来源:TestAttachments.java

示例9: getCallbackUrl

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Override
protected String getCallbackUrl(HtmlPage authorizationPage) throws Exception {
    HtmlForm form = authorizationPage.getForms().get(0);
    HtmlTextInput login = form.getInputByName("username");
    login.setValueAttribute("leleuj");
    HtmlPasswordInput passwd = form.getInputByName("password");
    passwd.setValueAttribute("leleuj");
    HtmlSubmitInput submit = form.getInputByName("submit");
    HtmlPage confirmPage = submit.click();
    HtmlAnchor allowLink = confirmPage.getAnchorByName("allow");
    HtmlPage callbackPage = allowLink.click();
    String callbackUrl = callbackPage.getUrl().toString();
    logger.debug("callbackUrl : {}", callbackUrl);
    return callbackUrl;
}
 
开发者ID:ameizi,项目名称:cas-oauth-example-3.5.x,代码行数:16,代码来源:TestCasWrapperProvider20.java

示例10: testLink

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Test
public void testLink() throws IOException {
    HtmlAnchor anchor = (HtmlAnchor)page.getElementById("link1");
    assertTrue(anchor.getHrefAttribute().contains("faces/login.xhtml"));
    assertEquals("Login1", anchor.asText());
    
    HtmlPage output = anchor.click();
    assertEquals("HTTP GET (Login)", output.getTitleText());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:10,代码来源:UserTest.java

示例11: testLinkWithParam

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Test
public void testLinkWithParam() throws IOException {
    HtmlAnchor anchor = (HtmlAnchor)page.getElementById("link2");
    assertTrue(anchor.getHrefAttribute().contains("faces/login.xhtml"));
    assertTrue(anchor.getHrefAttribute().contains("?name=Jack"));
    assertEquals("Login2", anchor.asText());
    
    HtmlPage output = anchor.click();
    assertEquals("HTTP GET (Login)", output.getTitleText());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:11,代码来源:UserTest.java

示例12: testCategoryOperations

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
@Test
public void testCategoryOperations() throws Exception {
	logger.info("start insert category");
	HtmlPage adminPage = webClient.getPage(base + "views/admin/index.xhtml");
	HtmlAnchor button = adminPage.getAnchors().get(2);
	HtmlPage page = button.click();
	HtmlForm addCategory = page.getFormByName("addCategoryForm");
	String categoryToInsert = "ccccc";
	addCategory.getInputByName("addCategoryForm:Category").setValueAttribute(categoryToInsert);
	HtmlSubmitInput submitButton = addCategory.getInputByName("addCategoryForm:editinline");
	page = submitButton.click();
	assertTrue("The category is created", page.asText().contains(categoryToInsert));
	HtmlAnchor adminPanel = adminPage.getAnchors().get(1);
	page = adminPanel.click();
	button = page.getAnchors().get(6);
	page = button.click();
	HtmlForm editCategory = page.getForms().get(4);
	String categoryToUpdate = "aaaaaa";
	String firstCategory = "Dummy demo category";
	editCategory.getInputByValue(categoryToInsert).setValueAttribute(categoryToUpdate);
	submitButton = editCategory.getInputByValue(resourceBundle.getString("Update"));
	page = submitButton.click();
	assertTrue("The category is updated", page.asText().contains(categoryToUpdate));
	button = page.getAnchors().get(7);
	page = button.click();
	assertTrue("The category is arrowed up",
			page.asText().indexOf(categoryToUpdate) < page.asText().indexOf(firstCategory));
	button = page.getAnchors().get(4);
	page = button.click();
	assertTrue("The category is arrowed down",
			page.asText().indexOf(categoryToUpdate) > page.asText().indexOf(firstCategory));
	button = page.getAnchors().get(8);
	page = button.click();
	HtmlForm deleteCategory = page.getForms().get(1);
	submitButton = deleteCategory.getInputByValue(resourceBundle.getString("Cancel"));
	page = submitButton.click();
	assertTrue("The delete is canceled",
			page.asText().contains(firstCategory) && page.asText().contains(categoryToUpdate));
	button = page.getAnchors().get(0);
	page = button.click();
	assertTrue("In the home page there are two categories",
			page.asText().contains(firstCategory) && page.asText().contains(categoryToUpdate));
	button = page.getAnchors().get(1);
	page = button.click();
	button = page.getAnchors().get(8);
	page = button.click();
	deleteCategory = page.getForms().get(1);
	submitButton = deleteCategory.getInputByValue(resourceBundle.getString("Confirm"));
	page = submitButton.click();
	assertTrue("The delete is confirmed", page.asText()
			.contains("\"" + categoryToUpdate + "\" " + resourceBundle.getString("Category_deleted_1")));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:53,代码来源:ApplicationTestCase.java

示例13: clickAttachmentsLink

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
public static HtmlPage clickAttachmentsLink(final HtmlPage page, final String name) throws IOException {
  HtmlAnchor attachmentsLink = page.getAnchorByName("attachments");
  assertEquals("Attachments", attachmentsLink.asText());
  HtmlPage attachments = (HtmlPage) attachmentsLink.click();
  return attachments;
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:7,代码来源:WebTestSupport.java

示例14: testCanViewHistoryForDeletedPage

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
public void testCanViewHistoryForDeletedPage() throws Exception {
  HtmlPage deleted = createThenDeletePage()._page;
  HtmlAnchor historyLink = deleted.getAnchorByName("history");
  // This used to give an error.
  historyLink.click();
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:7,代码来源:TestDeletedPages.java

示例15: getTextAttachmentAtEndOfLink

import com.gargoylesoftware.htmlunit.html.HtmlAnchor; //导入方法依赖的package包/类
public static String getTextAttachmentAtEndOfLink(final HtmlAnchor link) throws IOException {
  TextPage attachment = (TextPage) link.click();
  return attachment.getContent().trim();
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:5,代码来源:TestAttachments.java


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