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


Java HtmlButton.click方法代码示例

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


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

示例1: testCreateNewDatastream

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
@Ignore("The htmlunit web client can't handle the HTML5 file API")
public void testCreateNewDatastream() throws IOException {

    final String pid = randomUUID().toString();

    // can't do this with javascript, because HTMLUnit doesn't speak the HTML5 file api
    final HtmlPage page = webClient.getPage(serverAddress);
    final HtmlForm form = (HtmlForm)page.getElementById("action_create");

    final HtmlInput slug = form.getInputByName("slug");
    slug.setValueAttribute(pid);

    final HtmlSelect type = (HtmlSelect)page.getElementById("new_mixin");
    type.getOptionByValue("binary").setSelected(true);

    final HtmlFileInput fileInput = (HtmlFileInput)page.getElementById("datastream_payload");
    fileInput.setData("abcdef".getBytes());
    fileInput.setContentType("application/pdf");

    final HtmlButton button = form.getFirstByXPath("button");
    button.click();

    final HtmlPage page1 = javascriptlessWebClient.getPage(serverAddress + pid);
    assertEquals(serverAddress + pid, page1.getTitleText());
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:27,代码来源:FedoraHtmlResponsesIT.java

示例2: testCreateTasks

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
	public void testCreateTasks() throws Exception {

		HtmlPage createTaskPage = webClient.getPage("http://localhost:8080/tasks/new");

		HtmlForm form = createTaskPage.getHtmlElementById("form");
		HtmlTextInput nameInput = createTaskPage.getHtmlElementById("name");
		nameInput.setValueAttribute("My first task");
		HtmlTextArea descriptionInput = createTaskPage.getHtmlElementById("description");
		descriptionInput.setText("Description of my first task");
		HtmlButton submit = form.getOneHtmlElementByAttribute("button", "type", "submit");
		HtmlPage taskListPage = submit.click();

		Assertions.assertThat(taskListPage.getUrl().toString()).endsWith("/tasks");
//		String id = taskListPage.getHtmlElementById("todolist").getTextContent();
//		assertThat(id).isEqualTo("123");
//		String summary = newMessagePage.getHtmlElementById("summary").getTextContent();
//		assertThat(summary).isEqualTo("Spring Rocks");
//		String text = newMessagePage.getHtmlElementById("text").getTextContent();
//		assertThat(text).isEqualTo("In case you didn't know, Spring Rocks!");

	}
 
开发者ID:hantsy,项目名称:spring4-sandbox,代码行数:23,代码来源:MockMvcWebClientCreateTaskTests.java

示例3: createAndVerifyObjectWithIdFromRootPage

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
private HtmlPage createAndVerifyObjectWithIdFromRootPage(final String pid) throws IOException {
    final HtmlPage page = webClient.getPage(serverAddress);
    final HtmlForm form = (HtmlForm)page.getElementById("action_create");
    final HtmlSelect type = (HtmlSelect)page.getElementById("new_mixin");
    type.getOptionByValue("container").setSelected(true);

    final HtmlInput new_id = (HtmlInput)page.getElementById("new_id");
    new_id.setValueAttribute(pid);
    final HtmlButton button = form.getFirstByXPath("button");
    button.click();


    try {
        final HtmlPage page1 = webClient.getPage(serverAddress + pid);
        assertEquals("Page had wrong title!", serverAddress + pid, page1.getTitleText());
        return page1;
    } catch (final FailingHttpStatusCodeException e) {
        fail("Did not successfully retrieve created page! Got HTTP code: " + e.getStatusCode());
        return null;
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:22,代码来源:FedoraHtmlResponsesIT.java

示例4: testCreateNewDatastreamWithNoFileAttached

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
public void testCreateNewDatastreamWithNoFileAttached() throws IOException {

    final String pid = randomUUID().toString();

    // can't do this with javascript, because HTMLUnit doesn't speak the HTML5 file api
    final HtmlPage page = webClient.getPage(serverAddress);
    final HtmlForm form = (HtmlForm)page.getElementById("action_create");

    final HtmlInput slug = form.getInputByName("slug");
    slug.setValueAttribute(pid);

    final HtmlSelect type = (HtmlSelect)page.getElementById("new_mixin");
    type.getOptionByValue("binary").setSelected(true);

    final HtmlButton button = form.getFirstByXPath("button");
    button.click();

    javascriptlessWebClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    final int status = javascriptlessWebClient.getPage(serverAddress + pid).getWebResponse().getStatusCode();
    assertEquals(NOT_FOUND.getStatusCode(), status);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:23,代码来源:FedoraHtmlResponsesIT.java

示例5: testCreateNewObjectAndSetProperties

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
@Ignore
public void testCreateNewObjectAndSetProperties() throws IOException {
    final String pid = createNewObject();

    final HtmlPage page = javascriptlessWebClient.getPage(serverAddress + pid);
    final HtmlForm form = (HtmlForm)page.getElementById("action_sparql_update");
    final HtmlTextArea sparql_update_query = (HtmlTextArea)page.getElementById("sparql_update_query");
    sparql_update_query.setText("INSERT { <> <info:some-predicate> 'asdf' } WHERE { }");

    final HtmlButton button = form.getFirstByXPath("button");
    button.click();

    final HtmlPage page1 = javascriptlessWebClient.getPage(serverAddress + pid);
    assertTrue(page1.getElementById("metadata").asText().contains("some-predicate"));
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:17,代码来源:FedoraHtmlResponsesIT.java

示例6: roomBooking

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的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

示例7: selectEmailRecoveryAsSignInChallenge

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
private HtmlPage selectEmailRecoveryAsSignInChallenge(WebClient webClient, HtmlPage signInChallengePage)
		throws IOException {
	List<HtmlForm> forms = signInChallengePage.getForms();
	Optional<HtmlForm> kpeForm = forms.stream()
			.filter(form -> "/signin/challenge/kpe/2".equals(form.getActionAttribute())).findFirst();
	if (!kpeForm.isPresent()) {
		throw new RuntimeException(
				"Cannot find recovery by email form in html page :\n" + signInChallengePage.asXml());
	}
	HtmlButton button = (HtmlButton) kpeForm.get().getElementsByTagName("button").get(0);
	HtmlPage htmlPage = button.click();
	webClient.waitForBackgroundJavaScriptStartingBefore(WAIT_DELAY_MS);
	return htmlPage;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:15,代码来源:HtmlUnitAuthorizationCodeInstalledApp.java

示例8: testLeaveCalendarPage

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
public void testLeaveCalendarPage() throws Exception {
	// get the page and Login
	HtmlPage leaveCalendarPage = HtmlUnitUtil
			.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_CALENDAR_URL+"?documentId=" + documentId, true);
	Assert.assertNotNull("Leave Request page not found" ,leaveCalendarPage);

	//this.setWebClient(leaveCalendarPage.getWebClient());

	Assert.assertTrue("Page does not have Current calendar ", leaveCalendarPage.asText().contains("March 2012"));

       // Check for next document
       HtmlButton nextButton = (HtmlButton) leaveCalendarPage
               .getElementById("nav_next_lc");
       Assert.assertNotNull(nextButton);
       //TODO: click not working.  Not even getting to the 'execute' method in LeaveCalendarAction
       HtmlPage page = nextButton.click();
       Assert.assertNotNull(page);
       
       synchronized (page) {
           page.wait(5000);
       }
       String pageText = page.asText();
       LOG.info(pageText);
	// Check for previous document
	HtmlButton prevButton = (HtmlButton) page
			.getElementById("nav_prev_lc");
	Assert.assertNotNull(prevButton);
       page = prevButton.click();
       Assert.assertNotNull(page);

}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:33,代码来源:LeaveCalendarWebTest.java

示例9: testCreateNewNodeWithGeneratedId

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
public void testCreateNewNodeWithGeneratedId() throws IOException {

    final HtmlPage page = webClient.getPage(serverAddress);
    final HtmlForm form = (HtmlForm)page.getElementById("action_create");
    final HtmlSelect type = (HtmlSelect)page.getElementById("new_mixin");
    type.getOptionByValue("container").setSelected(true);
    final HtmlButton button = form.getFirstByXPath("button");
    button.click();

    final HtmlPage page1 = javascriptlessWebClient.getPage(serverAddress);
    assertTrue("Didn't see new information in page!", !page1.asText().equals(page.asText()));
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:14,代码来源:FedoraHtmlResponsesIT.java

示例10: testSparqlSearch

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
@Ignore("htmlunit can't see links in the HTML5 <nav> element..")
public void testSparqlSearch() throws IOException {
    final HtmlPage page = webClient.getPage(serverAddress);

    logger.error(page.toString());
    page.getAnchorByText("Search").click();

    final HtmlForm form = (HtmlForm)page.getElementById("action_sparql_select");
    final HtmlTextArea q = form.getTextAreaByName("q");
    q.setText("SELECT ?subject WHERE { ?subject a <" + REPOSITORY_NAMESPACE + "Resource> }");
    final HtmlButton button = form.getFirstByXPath("button");
    button.click();
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:15,代码来源:FedoraHtmlResponsesIT.java

示例11: clickButtonIgnoringVisibility

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
private HtmlPage clickButtonIgnoringVisibility(HtmlButton htmlButton) throws IOException {
	MouseEvent event = new MouseEvent(htmlButton, MouseEvent.TYPE_CLICK, false, false, false,
			MouseEvent.BUTTON_LEFT);
	return htmlButton.click(event, true);
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:6,代码来源:HtmlUnitAuthorizationCodeInstalledApp.java

示例12: testLeaveBlockDisplayPage

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
@Test
public void testLeaveBlockDisplayPage() throws Exception {
	// get the page and Login
	HtmlPage leaveBlockDisplayPage = HtmlUnitUtil
			.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_BLOCK_DISPLAY_URL);
	Assert.assertNotNull("Leave Request page not found" + leaveBlockDisplayPage);

	updateWebClient();

	// check page contains the current year
	Assert.assertTrue("Page is not current year ",
			leaveBlockDisplayPage.asText().contains(YEAR));

	// Check Main section
	// depends on injection of test data for current year.
	Assert.assertTrue("Page does not contain planned leave ",
			leaveBlockDisplayPage.asText().contains("Send for Approval"));

	// check Days Removed in correction section
	Assert.assertTrue("Page does not contain approved leaves ",
			leaveBlockDisplayPage.asText().contains("Updated by others"));
	
	// check Inactive Leave entries
	Assert.assertTrue("Page does not contain approved leaves ",
			leaveBlockDisplayPage.asText().contains("Updated by self"));
	
	// check page contains Document Status column
	Assert.assertTrue("Page does not contain Document Status ",
			leaveBlockDisplayPage.asText().contains("Document Status"));
	Assert.assertTrue("Page does not contain 'FINAL' Document Status ",
			leaveBlockDisplayPage.asText().contains("FINAL"));
	
	// check page contains Planning Status column
	Assert.assertTrue("Page does not contain Planning Status ",
			leaveBlockDisplayPage.asText().contains("Planning Status"));
	
	// Check for next year
	HtmlButton nextButton = (HtmlButton) leaveBlockDisplayPage
			.getElementById("nav_lb_next");
	leaveBlockDisplayPage = nextButton.click();

	// check page contains the next year
	Assert.assertTrue("Page does not contain next year ",
			leaveBlockDisplayPage.asText().contains(String.valueOf(Integer.valueOf(YEAR) + 1)));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:46,代码来源:LeaveBlockDisplayWebTest.java

示例13: takeSnapshotAndMakeSureSomethingHappens

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
/**
 * Integration test that simulates the user action of clicking the button to generate the bundle.
 *
 * <p>
 * If any warning is reported to j.u.l logger, treat that as a sign of failure, because
 * support-core plugin works darn hard to try to generate something in the presence of failing
 * {@link Component} impls.
 */
@Test
public void takeSnapshotAndMakeSureSomethingHappens() throws Exception {
    rule.createSlave("slave1","test",null).getComputer().connect(false).get();
    rule.createSlave("slave2","test",null).getComputer().connect(false).get();

    RingBufferLogHandler checker = new RingBufferLogHandler();
    Logger logger = Logger.getLogger(SupportPlugin.class.getPackage().getName());

    logger.addHandler(checker);

    try {
        WebClient wc = rule.createWebClient();
        HtmlPage p = wc.goTo(root.getUrlName());

        HtmlForm form = p.getFormByName("bundle-contents");
        HtmlButton submit = (HtmlButton) form.getHtmlElementsByTagName("button").get(0);
        Page zip = submit.click();
        File zipFile = File.createTempFile("test", "zip");
        IOUtils.copy(zip.getWebResponse().getContentAsStream(), zipFile);

        ZipFile z = new ZipFile(zipFile);

        // check the presence of files
        // TODO: emit some log entries and see if it gets captured here
        assertNotNull(z.getEntry("about.md"));
        assertNotNull(z.getEntry("nodes.md"));
        assertNotNull(z.getEntry("nodes/master/thread-dump.txt"));

        if (SystemPlatform.LINUX == SystemPlatform.current()) {
            List<String> files = Arrays.asList("proc/swaps.txt",
                                                   "proc/cpuinfo.txt",
                                                   "proc/mounts.txt",
                                                   "proc/system-uptime.txt",
                                                   "proc/net/rpc/nfs.txt",
                                                   "proc/net/rpc/nfsd.txt",
                                                   "proc/meminfo.txt",
                                                   "proc/self/status.txt",
                                                   "proc/self/cmdline",
                                                   "proc/self/environ",
                                                   "proc/self/limits.txt",
                                                   "proc/self/mountstats.txt",
                                                   "sysctl.txt",
                                                   "dmesg.txt",
                                                   "userid.txt",
                                                   "dmi.txt");

            for (String file : files) {
                assertNotNull(file +" was not found in the bundle",
                              z.getEntry("nodes/master/"+file));
            }
        }
    } finally {
        logger.removeHandler(checker);
        for (LogRecord r : checker.getView()) {
            if (r.getLevel().intValue() >= Level.WARNING.intValue()) {
                Throwable thrown = r.getThrown();
                if (thrown != null)
                    thrown.printStackTrace(System.err);

                fail(r.getMessage());
            }
        }
    }
}
 
开发者ID:jenkinsci,项目名称:support-core-plugin,代码行数:73,代码来源:SupportActionTest.java

示例14: createNewObject

import com.gargoylesoftware.htmlunit.html.HtmlButton; //导入方法依赖的package包/类
private String createNewObject() throws IOException {

        final String pid = randomUUID().toString();

        final HtmlPage page = webClient.getPage(serverAddress);
        final HtmlForm form = page.getFormByName("action_create");

        final HtmlInput slug = form.getInputByName("slug");
        slug.setValueAttribute(pid);

        final HtmlButton button = form.getFirstByXPath("button");
        button.click();

        webClient.waitForBackgroundJavaScript(1000);
        webClient.waitForBackgroundJavaScriptStartingBefore(10000);


        return pid;
    }
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:20,代码来源:FedoraHtmlResponsesIT.java


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