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


Java HtmlElement.click方法代码示例

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


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

示例1: setAttribute

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
public static boolean setAttribute(HtmlPage htmlPage, String xpath,
		String key, String value) {
	boolean flag = true;
	try {
		HtmlElement element = htmlPage.getFirstByXPath(xpath);
		if (element != null) {
			element.click();
			element.setAttribute(key, "");
			element.setAttribute(key, value);
		} else {
			logger.error("setAttribute element is null xpath " + xpath);
		}

	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		flag = false;
	}
	return flag;
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:20,代码来源:HtmlUnitUtil.java

示例2: testWeeklyOvertimeRuleMaint

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
	public void testWeeklyOvertimeRuleMaint() throws Exception {
		HtmlPage maintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.WEEKLY_OVERTIME_RULE_MAINT_URL);
		Assert.assertTrue("Maintenance Page contains test WeeklyOvertimeRule",maintPage.asText().contains(TEST_CODE));
		
		// test Convert from EarnCodeGroup has overtime earn codes error		
		HtmlPage newMaintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.WEEKLY_OVERTIME_RULE_MAINT_NEW_URL);
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.documentHeader.documentDescription", "Test");
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.effectiveDate", "01/01/2010");
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHoursEarnGroup", "REG");
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertFromEarnGroup", "OVT");
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertToEarnCode", "RGN");
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.step", "1");
		HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHours", "8");
//		HtmlPage finalPage = HtmlUnitUtil.clickInputContainingText(newMaintPage, "add");
		HtmlElement element = (HtmlElement)newMaintPage.getElementById("methodToCall.addLine.lstWeeklyOvertimeRules.(!!org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule!!)");
        HtmlPage finalPage = element.click();
		Assert.assertTrue("Maintenance Page should contains EarnCodeGroup has overtime earn code error",
				finalPage.asText().contains("Earn Group 'OVT' has overtime earn codes."));
	}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:21,代码来源:WeeklyOvertimeRuleMaintenanceTest.java

示例3: testErrorMessages

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testErrorMessages() throws Exception {
  	String baseUrl = TkTestConstants.Urls.TIME_OFF_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "System Scheduled Time Off - test");
  	// use past dates
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2011");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.accruedDate", "04/01/2011");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.scheduledTimeOffDate", "04/01/2011");
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain:\n" + HrTestConstants.EFFECTIVE_DATE_ERROR, page.asText().contains(HrTestConstants.EFFECTIVE_DATE_ERROR));
  	Assert.assertTrue("page text does not contain:\n" + ACCRUED_DATE_PAST_ERROR, page.asText().contains(ACCRUED_DATE_PAST_ERROR));
  	Assert.assertTrue("page text does not contain:\n" + SCHEDULED_TO_DATE_PAST_ERROR, page.asText().contains(SCHEDULED_TO_DATE_PAST_ERROR));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:23,代码来源:SystemScheduledTimeOffMaintTest.java

示例4: testRequiredFields

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testRequiredFields() throws Exception {
  	String baseUrl = TkTestConstants.Urls.LEAVE_ADJUSTMENT_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain:\n" + EFFECTIVE_DATE_REQUIRED, page.asText().contains(EFFECTIVE_DATE_REQUIRED));
  	Assert.assertTrue("page text does not contain:\n" + PRINCIPAL_ID_REQUIRED, page.asText().contains(PRINCIPAL_ID_REQUIRED));
  	Assert.assertTrue("page text does not contain:\n" + LEAVE_PLAN_REQUIRED, page.asText().contains(LEAVE_PLAN_REQUIRED));
  	Assert.assertTrue("page text does not contain:\n" + ACCRUAL_CATEGORY_REQUIRED, page.asText().contains(ACCRUAL_CATEGORY_REQUIRED));
  	Assert.assertTrue("page text does not contain:\n" + EARN_CODE_REQUIRED, page.asText().contains(EARN_CODE_REQUIRED));
  	Assert.assertTrue("page text does not contain:\n" + DES_REQUIRED, page.asText().contains(DES_REQUIRED));
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.adjustmentAmount", "");
    element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain:\n" + ADJUSTMENT_AMOUNT_REQUIRED, page.asText().contains(ADJUSTMENT_AMOUNT_REQUIRED));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:26,代码来源:LeaveAdjustmentMaintTest.java

示例5: testRequiredFields

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testRequiredFields() throws Exception {
  	String baseUrl = HrTestConstants.Urls.INSTITUTION_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain:\n" + "Effective Date (Effective Date) is a required field.", 
  			page.asText().contains("Effective Date (Effective Date) is a required field."));
  	Assert.assertTrue("page text does not contain:\n" + "Institution Code (Institution Code) is a required field.", 
  			page.asText().contains("Institution Code (Institution Code) is a required field."));

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

示例6: runTest

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void runTest() throws Throwable {
	// trigger the rule
	if ("click".equals(_triggerType)) {
		Selectors selectors = new Selectors(new W3CNode(_page));
		HtmlElement el = (HtmlElement) selectors.querySelector(_triggerElement);
		if (null != el)
			el.click();
	}

	// wait a sec
	Thread.sleep(1000l);

	// get the list of Rules which fired on the page
	Object logEntries = _page.executeJavaScript("_satellite.Logger.getHistory()").getJavaScriptResult();
	if (NativeArray.class.isAssignableFrom(logEntries.getClass())) {
		for (Iterator<NativeArray> iter = ((NativeArray) logEntries).iterator(); iter.hasNext();) {
			NativeArray line = iter.next();
			String logMessage = line.get(1).toString();
			if (logMessage.startsWith("Rule ") && logMessage.endsWith("fired.")) {
				String ruleName = logMessage.replace("Rule \"", "").replace("\" fired.", "");
				if (ruleName.equals(_ruleName)) {
					// yay, it fired! It's a pass!
					return;
				}
			}
		}
	}

	// didn't find the rule? Well...
	fail(Tools.DTM + " EBR " + _ruleName + "doesn't fire");
}
 
开发者ID:janexner,项目名称:site-infrastructure-tests,代码行数:34,代码来源:DTMEventBasedRuleHasRunTestCase.java

示例7: execute

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void execute(Context context)
{
	LoggerFactory.getLogger(ClickElement.class).debug("Executing action: " + this);
	HtmlElement element = context.getXPathProcessor().getSingleElementOfType(Util.getCurrentPage(context), Util.replacePlaceholders(path, context), HtmlElement.class);
	try
	{
		element.click();
	}
	catch(IOException e)
	{
		throw new RuntimeException(e);
	}
}
 
开发者ID:sropelato,项目名称:Fetchino,代码行数:18,代码来源:ClickElement.java

示例8: login

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
public static boolean login(WebClient client, String userName,
		String passWrod) throws Exception {
	boolean flag = false;
	try {
		String s = "https://passport.sina.cn/signin/signin?entry=wapsso&vt=4&r=http%3A%2F%2Fmy.sina.cn%2F%3Fpos%3D108%26vt%3D4%26m%3D78fc51068140045a973a3aeab4db2381&amp;revalid=1";
		HtmlPage page = client.getPage(s);
		// <input type="text" placeholder="微博帐号/手机号/邮箱" autocorrect="off"
		// autocapitalize="off" id="loginName">

		HtmlInput htmlInput = page
				.getFirstByXPath("//input[@id='loginName']");
		htmlInput.click();
		htmlInput.setAttribute("value", userName);

		// <input type="password" placeholder="密码" id="loginPassword">
		htmlInput = page.getFirstByXPath("//input[@id='loginPassword']");
		htmlInput.click();
		htmlInput.setAttribute("value", passWrod);

		// <a id="loginAction" class="btn_login" href="javascript:;">登录</a>

		HtmlElement a = page.getFirstByXPath("//a[@id='loginAction']");
		page = a.click();

		client.setJavaScriptTimeout(5000);
		String str = page.asXml();
		if (!str.contains("QQ帐号登录")) {
			flag = true;
			logger.error("登录成功");
		}
	} catch (Exception e) {
		logger.error(e);
		flag = false;
	}
	return flag;
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:37,代码来源:HtmlUnitUtil.java

示例9: testEntries

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

示例10: testRequiredFields

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testRequiredFields() throws Exception {
  	String baseUrl = TkTestConstants.Urls.TIME_OFF_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	//default value for premium holiday is no
  	Assert.assertTrue("Preminum Holiday is not default to No", page.getHtmlElementById("document.newMaintainableObject.premiumHolidayNo").asText().equals("checked"));
  		  	
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain:\n" + EFFECTIVE_DATE_REQUIRED, page.asText().contains(EFFECTIVE_DATE_REQUIRED));
    Assert.assertTrue("page text does not contain:\n" + LEAVE_PLAN_REQUIRED, page.asText().contains(LEAVE_PLAN_REQUIRED));
    Assert.assertTrue("page text does not contain:\n" + ACCRUAL_CATEGORY_REQUIRED, page.asText().contains(ACCRUAL_CATEGORY_REQUIRED));
    Assert.assertTrue("page text does not contain:\n" + EARN_CODE_REQUIRED, page.asText().contains(EARN_CODE_REQUIRED));
    
    Assert.assertTrue("page text does not contain:\n" + ACCRUED_DATE_REQUIRED, page.asText().contains(ACCRUED_DATE_REQUIRED));
    Assert.assertTrue("page text does not contain:\n" + LOCATION_REQUIRED, page.asText().contains(LOCATION_REQUIRED));
    Assert.assertTrue("page text does not contain:\n" + DESCRIPTION_REQUIRED, page.asText().contains(DESCRIPTION_REQUIRED));
    Assert.assertTrue("page text does not contain:\n" + AMOUNT_OF_TIME_REQUIRED, page.asText().contains(AMOUNT_OF_TIME_REQUIRED));
    //there should be a default value for premium holiday
    Assert.assertFalse("page text contains:\n" + PREMIUM_HOLIDAY_REQUIRED, page.asText().contains(PREMIUM_HOLIDAY_REQUIRED));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:29,代码来源:SystemScheduledTimeOffMaintTest.java

示例11: testAddNew

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testAddNew() throws Exception {
  	String baseUrl = TkTestConstants.Urls.LEAVE_ADJUSTMENT_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	
  	HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "Leave Adjustment - test");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2012");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.principalId", "admin");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.accrualCategory", "myAC");	//nonexist accrual catetory
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.earnCode", "myLC");	//nonexist leave Code
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	HtmlUnitUtil.createTempFile(page);
  	Assert.assertTrue("page text contains:\n" + "'myAC' does not exist", page.asText().contains("'myAC' does not exist"));
  	  	
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.accrualCategory", "AC1"); // existing accrual category
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.earnCode", "testLC");
  	element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertFalse("page text contains:\n" + "'AC1' does not exist", page.asText().contains("'AC1' does not exist"));
  	
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.principalId", "admin"); // existing principal hr attributes
  	element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertFalse("page text contains:\n" + "'IU-SM' does not exist", page.asText().contains("'IU-SM' does not exist"));
  	
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.earnCode", "EC");	//fraction allowed is 99.9
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.adjustmentAmount", "2.45");
  	element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain amount fraction error.", page.asText().contains("Earn Code 'EC' only allows 1 decimal point."));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:40,代码来源:LeaveAdjustmentMaintTest.java

示例12: testValidation

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testValidation() throws Exception {
  	String baseUrl = TkTestConstants.Urls.LEAVE_DONATION_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	
  	HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "Leave Donation - test");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2012");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.donatedEarnCode", "EC");	//fraction allowed is 99
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.amountDonated", "2.45");
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain donated amount fraction error.", page.asText().contains("Earn Code 'EC' only allows 0 decimal point."));
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.amountDonated", "2");
  	page = ((HtmlElement)page.getElementByName("methodToCall.route")).click();
  	Assert.assertFalse("page text contains donated amount fraction error.", page.asText().contains("Earn Code 'EC' only allows 0 decimal point."));
  	
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.recipientsEarnCode", "EC");	//fraction allowed is 99
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.amountReceived", "3.822");
  	element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	Assert.assertTrue("page text does not contain received amount fraction error.", page.asText().contains("Earn Code 'EC' only allows 0 decimal point."));
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.amountReceived", "3");
  	page = ((HtmlElement)page.getElementByName("methodToCall.route")).click();
  	Assert.assertFalse("page text contains received amount fraction error.", page.asText().contains("Earn Code 'EC' only allows 0 decimal point."));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:30,代码来源:LeaveDonationMaintTest.java

示例13: testRequiredFields

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testRequiredFields() throws Exception {
  	String baseUrl = TkTestConstants.Urls.SHIFT_DIFFERENTIAL_RULE_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	// the following fields should have default values
  	String errorMessage = "Min. Hours (Min. Hours) is a required field.";
  	Assert.assertFalse("page text contains:\n" + errorMessage, page.asText().contains(errorMessage));
    errorMessage = "Begin Time (00:00 AM) (Begin Time) is a required field.";
    Assert.assertFalse("page text contains:\n" + errorMessage, page.asText().contains(errorMessage));
    errorMessage = "End Time (00:00 AM) (End Time) is a required field.";
    Assert.assertFalse("page text contains:\n" + errorMessage, page.asText().contains(errorMessage));
    errorMessage = "Max. Gap Minutes (Max. Gap Minutes) is a required field.";
    Assert.assertFalse("page text contains:\n" + errorMessage, page.asText().contains(errorMessage));
  	
    //remove the default values
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.minHours", "");
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.beginTime", "");
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.endTime", "");
  	HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.maxGap", "");
  	element = page.getElementByName("methodToCall.route");
  	HtmlPage nextPage = element.click();
  	errorMessage = "Effective Date (Effective Date) is a required field.";
  	Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Location (Location) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Salary Group (Salary Group) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Pay Grade (Pay Grade) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Earn Code (Earn Code) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "From Earn Group (From Earn Group) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Begin Time (00:00 AM) (Begin Time) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "End Time (00:00 AM) (End Time) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Max. Gap Minutes (Max. Gap Minutes) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Pay Calendar Group (Pay Calendar Group) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "Min. Hours (Min. Hours) is a required field.";
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
    errorMessage = "At least one day must be checked."; // KPME-2635
    Assert.assertTrue("page text does not contain:\n" + errorMessage, nextPage.asText().contains(errorMessage));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:57,代码来源:ShiftDifferentialRuleMaintTest.java

示例14: testLeaveRequestPage

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

	// Check planned requests
	Assert.assertTrue("Page does not contain planned leave ", leaveRequestPage
			.asText().contains("Send for Approval"));

	// check Approved Leaves
	Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
			.asText().contains("Approved Leave"));

	// check disapproved Leaves
	Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
			.asText().contains("Disapprove"));

	HtmlCheckBoxInput htmlElement = (HtmlCheckBoxInput) leaveRequestPage
			.getElementByName("plannedLeaves[0].submit");
	leaveRequestPage = (HtmlPage) htmlElement.setValueAttribute("true");

	HtmlCheckBoxInput checkbox = (HtmlCheckBoxInput) HtmlUnitUtil
			.getInputContainingText(leaveRequestPage,
					"plannedLeaves[0].submit");
	checkbox.setChecked(true);

	HtmlElement elementSubmit = leaveRequestPage.getElementByName("Submit");
	Assert.assertNotNull(elementSubmit);

	HtmlUnitUtil.createTempFile(leaveRequestPage);

	HtmlPage leaveRequestPage1 = elementSubmit.click();

	HtmlUnitUtil.createTempFile(leaveRequestPage1);

	// check if submitted pending leave comes in the section of Requested
	// leave
	Assert.assertTrue("Page does not contain Pending leave ", leaveRequestPage1
			.asText().contains("Send for Approval"));

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

示例15: testCreatingLeaveBlocks

import com.gargoylesoftware.htmlunit.html.HtmlElement; //导入方法依赖的package包/类
@Test
public void testCreatingLeaveBlocks() throws Exception {
	DateTime START_DATE = new DateTime(2012, 4, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
	DateTime END_DATE = new DateTime(2012, 4, 2, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
	
	List<LeaveBlock> leaveBlockList;
	leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks("testuser1", START_DATE.toLocalDate(), END_DATE.toLocalDate());
	Assert.assertTrue("There are leave blocks for principal id " + "testuser1", leaveBlockList.isEmpty());
	leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks("testuser2", START_DATE.toLocalDate(), END_DATE.toLocalDate());
	Assert.assertTrue("There are leave blocks for principal id " + "testuser2", leaveBlockList.isEmpty());
	
	List<LeaveBlockHistory> historyList = LmServiceLocator.getLeaveBlockHistoryService().getLeaveBlockHistories("10001", null);
	Assert.assertTrue("There are leave block histories for princiapl id testuser1", historyList.isEmpty());
	historyList = LmServiceLocator.getLeaveBlockHistoryService().getLeaveBlockHistories("testuser2", null);
	Assert.assertTrue("There are leave block histories for princiapl id testuser2", historyList.isEmpty());
	
	String baseUrl = TkTestConstants.Urls.LEAVE_DONATION_MAINT_NEW_URL;
  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
  	Assert.assertNotNull(page);
 
  	HtmlForm form = page.getFormByName("KualiForm");
  	Assert.assertNotNull("Search form was missing from page.", form);
  	HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "Leave Donation - test");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2012");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.donorsPrincipalID", "testuser1");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.donatedAccrualCategory", "testAC");	
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.donatedEarnCode", "EC");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.amountDonated", "10");
    
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.recipientsPrincipalID", "testuser2");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.recipientsAccrualCategory", "testAC");	
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.recipientsEarnCode", "EC");
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.amountReceived", "8");
    
    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.description", "test-donation");
  	
  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
  	Assert.assertNotNull("Could not locate submit button", input);
  	HtmlElement element = page.getElementByName("methodToCall.route");
  	page = element.click();
  	page.asText();
  	Assert.assertTrue("page text does not contain: success ", page.asText().contains("success"));
  	
  	leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks("testuser1", START_DATE.toLocalDate(), END_DATE.toLocalDate());
  	Assert.assertTrue("There should be 1 leave blocks for emplyee 'testuser1', not " + leaveBlockList.size(), leaveBlockList.size()== 1);
  	LeaveBlock lb = leaveBlockList.get(0);
  	Assert.assertTrue("Hours of the leave block for donor 'testuser1' should be -10, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(-10)));
  	Assert.assertTrue("Request status of the leave block for donor 'testuser1' should be Approved, not " + lb.getRequestStatus()
  			, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
  	
	leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks("testuser2", START_DATE.toLocalDate(), END_DATE.toLocalDate());
	Assert.assertTrue("There should be 1 leave blocks for emplyee 'testuser2', not " + leaveBlockList.size(), leaveBlockList.size()== 1);
	lb = leaveBlockList.get(0);
	Assert.assertTrue("Hours of the leave block for recipient 'testuser2' should be 8, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(8)));
	Assert.assertTrue("Request status of the leave block for donor 'testuser2' should be Approved, not " + lb.getRequestStatus()
  			, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
  	
	historyList = LmServiceLocator.getLeaveBlockHistoryService().getLeaveBlockHistories("testuser1", null);
	Assert.assertTrue("There should be 1 leave block histories for princiapl id testuser1"+ historyList.size(), historyList.size()== 1);
	LeaveBlockHistory lbh = historyList.get(0);
	Assert.assertTrue("Hours of the leave block history for donor 'testuser1' should be -10, not " + lbh.getLeaveAmount().toString(), lbh.getLeaveAmount().equals(new BigDecimal(-10)));
	Assert.assertTrue("Request status of the leave block history for donor 'testuser1' should be Approved, not " + lbh.getRequestStatus()
  			, lbh.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
	historyList = LmServiceLocator.getLeaveBlockHistoryService().getLeaveBlockHistories("testuser2", null);
	Assert.assertTrue("There should be 1 leave block histories for princiapl id testuser2"+ historyList.size(), historyList.size()== 1);
	lbh = historyList.get(0);
	Assert.assertTrue("Hours of the leave block history for recipient 'testuser2' should be 8, not " + lbh.getLeaveAmount().toString(), lbh.getLeaveAmount().equals(new BigDecimal(8)));
	Assert.assertTrue("Request status of the leave block history for donor 'testuser2' should be Approved, not " + lbh.getRequestStatus()
  			, lbh.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:71,代码来源:LeaveDonationMaintTest.java


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