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


Java WebLink.click方法代码示例

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


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

示例1: testMain

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * Tests the administrator main page (main.jsp), by inspectin the treewidget
 * (actually a table) and verifying that there's the corect number of rows in
 * it in collapsed and expanded form.
 * @throws Exception
 */
@Test
public void testMain() throws Exception {
  getPage("index.jsp");
  clickOn("Click here to enter the Administrator Main Page.");
  login();
  
  // Check that the tree widget (in collapsed form) is of appropriate size.
  WebTable table = resp.getTables()[0];
  assertEquals( "rows", 5, table.getRowCount());
  assertEquals( "columns", 3, table.getColumnCount());
  
  // Expand the tree widget.
  WebLink link = table.getTableCell(0, 0).getLinks()[0];
  assertNotNull(link);
  link.click();
  resp = wc.getCurrentPage();
  
  // Check that the tree widget (in expanded form) is of appropriate size.
  table = resp.getTables()[0];
  assertEquals( "rows", 10, table.getRowCount());
  assertEquals( "columns", 3, table.getColumnCount());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:30,代码来源:AccessctlTest.java

示例2: multipleApplicationsLoginAndLogout

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
private void multipleApplicationsLoginAndLogout() throws Exception {
	// login 1
	WebConversation conversation = new WebConversation();
	WebRequest request = new GetMethodWebRequest(webssoClient2URL);
	WebResponse response = tryGetResponse(conversation, request);
	request = applicationLogin(conversation, response);
	response = tryGetResponse(conversation, request);
	assertUserInformation(response);

	// login 2
	WebRequest request2 = new GetMethodWebRequest(webssoClient2URL);// login into application2
	WebResponse response2 = tryGetResponse(conversation, request2);
	assertUserInformation(response2);

	// logout
	WebLink link = response.getLinkWith("logout");
	link.click(); // logout of the application
	WebRequest newRequest = new GetMethodWebRequest(webssoClient1URL);
	WebResponse outputResponse = tryGetResponse(conversation, newRequest);
	WebTable usersData = outputResponse
			.getTableStartingWith("Single Sign On User Data");

	assertNull("users data must be null ", usersData); // return null for user data (ie) logged out of second application
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:25,代码来源:AssertWebSSOApplicationStep.java

示例3: testFrameContainingBaseElement

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * Test that a link within a frame that contains a <code>&lt;base ...&gt;</code> element is handled correctly.
 */
public void testFrameContainingBaseElement() throws Exception {
    final String TARGET_TITLE = "Somewhere/Else/Target";
    defineWebPage( TARGET_TITLE,  "This is the target page." );
    defineWebPage( "Main",    "This is a simple page.");
    defineResource( "BaseRelLinker.html", getMenuHtml(getHostPath() + "/Somewhere/Near/", "../Else/Target.html") );
    redefineFrames("BaseRelLinker.html", "Main.html");

    _wc.getResponse( getHostPath() + "/Frames.html" );
    WebLink link = _wc.getFrameContents( "red" ).getLinks()[0];
    link.click();
    assertEquals("Content of blue frame after link click", TARGET_TITLE, _wc.getFrameContents("blue").getTitle());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:FrameScriptingTest.java

示例4: testFrameRewrittenToUseBaseElement

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * Test correct handling of a link within a frame that has been re-written by JavaScript,
 * and which contains a <code>&lt;base ...&gt;</code> element.
 */
public void testFrameRewrittenToUseBaseElement() throws Exception {
    redefineFrames("/Simple.html", "frameRewriter.html");
    _wc.getResponse(getHostPath() + "/Frames.html");
    WebLink link = _wc.getFrameContents("red").getLinks()[0];
    link.click();
    assertEquals("Content of blue frame after clicking menu link", "Menu/Page/Target", _wc.getFrameContents("blue").getTitle());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:FrameScriptingTest.java

示例5: testImageFrameRewrittenToUseBaseElement

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * Test correct handling of a link within a frame that has been re-written by JavaScript over an image,
 * and which contains a <code>&lt;base ...&gt;</code> element.
 */
public void testImageFrameRewrittenToUseBaseElement() throws Exception {
    redefineFrames("/image.gif", "frameRewriter.html");
    _wc.getResponse(getHostPath() + "/Frames.html");
    WebLink link = _wc.getFrameContents("red").getLinks()[0];
    link.click();
    assertEquals("Content of blue frame after clicking menu link", "Menu/Page/Target", _wc.getFrameContents("blue").getTitle());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:FrameScriptingTest.java

示例6: clickOn

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * Click on the link with a given text.
 * @param linkText The text of the link.
 * @throws SAXException
 * @throws IOException
 */
protected void clickOn(String linkText)
    throws SAXException, IOException {
  WebLink link = resp.getLinkWith(linkText);
 
  assertNotNull(link);
  link.click();
  resp = wc.getCurrentPage();
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:15,代码来源:AccessctlTest.java

示例7: clickFiltered

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * @param link
 * @throws IOException
 * @throws SAXException
 */
public void clickFiltered(WebLink link) throws IOException, SAXException {
  String text = link.asText();
  if (!("John Doe".equals(text) || "Gold Users".equals(text) 
      || "Private Administrative Users".equals(text))) {
    log.debug("Clicing Link: " + text);
    link.click();
    resp = wc.getCurrentPage();
  }
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:15,代码来源:AccessctlRandomizedTest.java

示例8: testImage

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testImage() throws Exception
{
    navigateToModelForEditing(myModelName);
    ResourceBundle theBundle = ResourceBundle.getBundle("test");

    // Adding
    WebLink theLink = myWebConversation.getCurrentPage().getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "Enter Images");
    assertNotNull("Unable to find link to enter a Image", theLink);
    WebResponse theCurrentPage = theLink.click();
    assertCurrentPageContains("(Image of type .jpg, .jpeg, .gif, .sid or .png)");
    WebForm theForm = theCurrentPage.getFormWithName("imageForm");                
    theForm.setParameter("fileLocation", new File(theBundle.getString("deploydir").trim() + "iconHelp.gif"));
    theForm.setParameter("title", "test image");
    theCurrentPage = theForm.submit();
    //TestUtil.getTextOnPage(theCurrentPage, "Error: Bad or missing data", "* indicates a required field");
    
    assertCurrentPageContains("You have successfully added an Image to this model!");

    // Editing
    theLink = myWebConversation.getCurrentPage().getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "test image");
    assertNotNull("Unable to find link to edit a Image", theLink);
    theCurrentPage = theLink.click();
    assertCurrentPageContains("(Image of type .jpg, .jpeg, .gif, .sid or .png)");
    theForm = theCurrentPage.getFormWithName("imageForm");
    // theForm.setParameter("fileLocation", new
    // File(theBundle.getString("imagedirectory")) );
    theForm.setParameter("title", "test image1");
    theCurrentPage = theForm.submit();
    assertCurrentPageContains("You have successfully edited an Image.");

    // Deleting
    theLink = myWebConversation.getCurrentPage().getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "test image1");
    assertNotNull("Unable to find link to delete a Image", theLink);
    theCurrentPage = theLink.click();
    assertCurrentPageContains("(Image of type .jpg, .jpeg, .gif, .sid or .png)");
    theForm = theCurrentPage.getFormWithName("imageForm");
    theForm.getSubmitButton("submitAction", "Delete").click();
    // TODO: Add check to see if Image is successfully removed from caIMAGE
    assertCurrentPageContains("You have successfully deleted an Image.");
}
 
开发者ID:NCIP,项目名称:camod,代码行数:41,代码来源:SubmitEditDeleteImageTest.java

示例9: testSearchForGeneDelivery

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testSearchForGeneDelivery() throws Exception {

		navigateToModelForEditing(myModelName);

		// Adding
		WebLink theLink = myWebConversation.getCurrentPage()
				.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT,
						"Enter Gene Delivery");
		assertNotNull("Unable to find link to enter a Gene Delivery", theLink);
		WebResponse theCurrentPage = theLink.click();
		assertCurrentPageContains("(if Viral Vector is not listed, then please");
		WebForm theWebForm = theCurrentPage.getFormWithName("geneDeliveryForm");

		GeneDeliveryForm theForm = new GeneDeliveryForm();
		theForm.setViralVector("Lentivirus");
		theForm.setOrgan("Heart");
		theForm.setOrganTissueName("Heart");
		theForm.setOrganTissueCode("C22498");

		// Add parameters found on submit screen but not displayed on search
		// screen
		List<String> theParamsToSkip = new ArrayList<String>();
		theParamsToSkip.add("organTissueCode");
		theParamsToSkip.add("organTissueName");

		TestUtil.setRandomValues(theForm, theWebForm, false, new ArrayList());
		TestUtil.setValuesOnForm(theForm, theWebForm);

		theCurrentPage = theWebForm.submit();
		assertCurrentPageContains("You have successfully added a Gene Delivery to this model!");

		TestUtil.moveModelToEditedApproved(myModelName);

		navigateToSpecificSearchPage(myModelName, "CARCINOGENIC INTERVENTIONS");

		verifyValuesOnPage(theWebForm, theParamsToSkip);
	}
 
开发者ID:NCIP,项目名称:camod,代码行数:38,代码来源:SearchPopulateCITest.java

示例10: testJacksonLab

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testJacksonLab() throws Exception {
	navigateToModelForEditing(myModelName);
    
    /* Find Model Availablity link to Submit */
    WebLink theLink = myWebConversation.getCurrentPage()
            .getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "Available from Jackson Lab.");
    WebResponse theCurrentPage = theLink.click(); 
    assertCurrentPageContains("Strain Name:");
    WebForm theForm = theCurrentPage.getFormWithName("availabilityForm");
    theForm.setParameter("name", "JJJJJ");
    theCurrentPage = theForm.submit();
    assertCurrentPageContains("You have successfully added an Availability to this model!");
    
    /* Find Model Availablity link to Edit */
    theLink = myWebConversation.getCurrentPage().getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "JJJJJ");        
    assertNotNull("Unable to find link to edit the Availability from Jackson Lab", theLink);        
    theCurrentPage = theLink.click();        
    assertCurrentPageContains("Strain Name:");
    theForm = theCurrentPage.getFormWithName("availabilityForm");
    theForm.setParameter("name", "ABCDEFG");
    theForm.setParameter("stockNumber", "2222");          
    theCurrentPage = theForm.submit();
    assertCurrentPageContains("You have successfully edited an Availability.");      
    
    /* Find Model Availablity link to Delete */
    theLink = myWebConversation.getCurrentPage().getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "ABCDEFG");
    assertNotNull("Unable to find link to delete the Availability from Jackson Lab", theLink);        
    theCurrentPage = theLink.click();        
    assertCurrentPageContains("Strain Name:");
    theForm = theCurrentPage.getFormWithName("availabilityForm");               
    theForm.getSubmitButton( "submitAction", "Delete" ).click();              
    assertCurrentPageContains("You have successfully deleted an Availability."); 
}
 
开发者ID:NCIP,项目名称:camod,代码行数:34,代码来源:SubmitEditDeleteModelAvailabilityTest.java

示例11: testSearchForRadiationWithOthers

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testSearchForRadiationWithOthers() throws Exception {

		navigateToModelForEditing(myModelName);

		// Adding
		WebLink theLink = myWebConversation.getCurrentPage()
				.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT,
						"Enter Radiation");
		assertNotNull("Unable to find link to enter a Radiation", theLink);
		WebResponse theCurrentPage = theLink.click();
		assertCurrentPageContains("(if Radiation is not listed, then please");
		WebForm theWebForm = theCurrentPage.getFormWithName("radiationForm");

		RadiationForm theForm = new RadiationForm();

		TestUtil.setRandomValues(theForm, theWebForm, true, new ArrayList());
		TestUtil.setValuesOnForm(theForm, theWebForm);

		theCurrentPage = theWebForm.submit();
		assertCurrentPageContains("You have successfully added a Radiation to this model!");

		TestUtil.moveModelToEditedApproved(myModelName);

		navigateToSpecificSearchPage(myModelName, "CARCINOGENIC INTERVENTIONS");

		verifyValuesOnPage(theWebForm);
	}
 
开发者ID:NCIP,项目名称:camod,代码行数:28,代码来源:SearchPopulateCITest.java

示例12: testSearchForGrowthFactor

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testSearchForGrowthFactor() throws Exception {

		navigateToModelForEditing(myModelName);

		// Adding
		WebLink theLink = myWebConversation.getCurrentPage()
				.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT,
						"Enter Growth Factor");
		assertNotNull("Unable to find link to enter a Growth Factor", theLink);
		WebResponse theCurrentPage = theLink.click();
		assertCurrentPageContains("(if Growth Factor is not listed, then please");
		WebForm theWebForm = theCurrentPage.getFormWithName("growthFactorForm");

		GrowthFactorForm theForm = new GrowthFactorForm();

		TestUtil.setRandomValues(theForm, theWebForm, false, new ArrayList());
		TestUtil.setValuesOnForm(theForm, theWebForm);

		theCurrentPage = theWebForm.submit();
		assertCurrentPageContains("You have successfully added a Growth Factor to this model!");

		TestUtil.moveModelToEditedApproved(myModelName);

		navigateToSpecificSearchPage(myModelName, "CARCINOGENIC INTERVENTIONS");

		verifyValuesOnPage(theWebForm);
	}
 
开发者ID:NCIP,项目名称:camod,代码行数:28,代码来源:SearchPopulateCITest.java

示例13: testSearchForEnvironmentalFactorWithOthers

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testSearchForEnvironmentalFactorWithOthers() throws Exception {

		navigateToModelForEditing(myModelName);

		// Adding
		WebLink theLink = myWebConversation.getCurrentPage()
				.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT,
						"Enter Environmental Factor");
		assertNotNull("Unable to find link to enter an Environmental Factor",
				theLink);
		WebResponse theCurrentPage = theLink.click();
		assertCurrentPageContains("(if Enviromental Factor is not listed, then please");
		WebForm theWebForm = theCurrentPage
				.getFormWithName("environmentalFactorForm");

		EnvironmentalFactorForm theForm = new EnvironmentalFactorForm();

		TestUtil.setRandomValues(theForm, theWebForm, true, new ArrayList());
		TestUtil.setValuesOnForm(theForm, theWebForm);

		theCurrentPage = theWebForm.submit();
		// added for debugging purpose only - comment out when done
		//TestUtil.getTextOnPage(theCurrentPage, "Error: Bad or missing data", "* indicates a required field");

		assertCurrentPageContains("You have successfully added an Environmental Factor to this model!");

		TestUtil.moveModelToEditedApproved(myModelName);

		navigateToSpecificSearchPage(myModelName, "CARCINOGENIC INTERVENTIONS");

		verifyValuesOnPage(theWebForm);
	}
 
开发者ID:NCIP,项目名称:camod,代码行数:33,代码来源:SearchPopulateCITest.java

示例14: testSearchForGrowthFactorWithOthers

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
public void testSearchForGrowthFactorWithOthers() throws Exception {

		navigateToModelForEditing(myModelName);

		// Adding
		WebLink theLink = myWebConversation.getCurrentPage()
				.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT,
						"Enter Growth Factor");
		assertNotNull("Unable to find link to enter a Growth Factor", theLink);
		WebResponse theCurrentPage = theLink.click();
		assertCurrentPageContains("(if Growth Factor is not listed, then please");
		WebForm theWebForm = theCurrentPage.getFormWithName("growthFactorForm");

		GrowthFactorForm theForm = new GrowthFactorForm();

		TestUtil.setRandomValues(theForm, theWebForm, true, new ArrayList());
		TestUtil.setValuesOnForm(theForm, theWebForm);

		theCurrentPage = theWebForm.submit();
		assertCurrentPageContains("You have successfully added a Growth Factor to this model!");

		TestUtil.moveModelToEditedApproved(myModelName);

		navigateToSpecificSearchPage(myModelName, "CARCINOGENIC INTERVENTIONS");

		verifyValuesOnPage(theWebForm);
	}
 
开发者ID:NCIP,项目名称:camod,代码行数:28,代码来源:SearchPopulateCITest.java

示例15: processLinks

import com.meterware.httpunit.WebLink; //导入方法依赖的package包/类
/**
 * @param resp
 * @param i
 * @param maxDepth
	 * @throws SAXException 
	 * @throws IOException 
 */
private void processLinks(WebResponse resp, int i, int maxDepth) throws SAXException, IOException
{
	char[] p = new char[i];
	for (int j = 0; j < i; j++)
	{
		p[j] = ' ';
	}
	String pad = new String(p);
	WebLink[] links = resp.getLinks();
	for (WebLink link : links)
	{
		String url = link.getURLString();
		if (visited.get(url) == null)
		{
			visited.put(url, url);
			if (isLocal(url))
			{
				log.info("Getting " + pad + link.getURLString());
				WebResponse response = null;
				try
				{

					response = link.click();
				}
				catch (HttpException ex)
				{
					log.warn("Failed to get Link " + url + " code:"
							+ ex.getResponseCode() + " cause:"
							+ ex.getResponseMessage());
				}
				catch (ConnectException cex)
				{
					log.error("Failed to get Connection to "+url);
				}
				if (response != null)
				{
					clickAll(response, i, maxDepth);
				}

			}
			else
			{
				log.info("Ignoring External URL " + url);
			}
		}
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:55,代码来源:AnonPortalTest.java


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