本文整理汇总了Java中com.gargoylesoftware.htmlunit.html.HtmlPasswordInput.setValueAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlPasswordInput.setValueAttribute方法的具体用法?Java HtmlPasswordInput.setValueAttribute怎么用?Java HtmlPasswordInput.setValueAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gargoylesoftware.htmlunit.html.HtmlPasswordInput
的用法示例。
在下文中一共展示了HtmlPasswordInput.setValueAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mockLogin
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public String mockLogin(URL url, String username, String password) {
try {
HtmlPage page1 = webClient.getPage(url.getURLValue());
// find the login form
HtmlForm form = page1.getForms().get(0);
// fill in the input
HtmlInput hi = form.getInputByName("commit");
HtmlTextInput textField = form.getInputByName("login");
HtmlPasswordInput pass = form.getInputByName("password");
textField.click();
textField.setValueAttribute(username);
pass.click();
pass.setValueAttribute(password);
// push the button
HtmlPage page2 = hi.click();
return page2.asXml();
} catch(IOException ioe) {
ioe.printStackTrace();
return null;
}
}
示例2: loadPage
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public void loadPage() {
try {
// Store cookies
cookieManager = webClient.getCookieManager();
page = webClient.getPage(URL);
HtmlForm form = page.getFormByName("processLogonForm");
HtmlSubmitInput button = form.getInputByName("Login");
HtmlTextInput user = form.getInputByName("userName");
HtmlPasswordInput pass = form.getInputByName("password");
user.setValueAttribute(username);
pass.setValueAttribute(password);
page = button.click();
if (page.asXml().contains("* Please try again.")) {
loginSuc = false;
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: logIn
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
private void logIn()throws IOException{
final HtmlPage page = browser.getPage("http://codeforces.com/enter");
final HtmlTextInput handle = (HtmlTextInput)page.getByXPath("//input[@id='handle']").get(0);
final HtmlPasswordInput pass = (HtmlPasswordInput)page.getByXPath("//input[@id='password']").get(0);
final HtmlSubmitInput btn = (HtmlSubmitInput)page.getByXPath("//input[@class='submit']").get(0);
// Change the value of the text fields
handle.setValueAttribute(user_name);
pass.setValueAttribute(pass_word);
// Now submit the form by clicking the button
btn.click();
}
示例4: login
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public void login(JSONObject accountProperties){
this.logger.info("네이버에 로그인합니다: " + accountProperties.getString("username"));
try{
final HtmlPage loginPage = this.getPage("https://nid.naver.com/nidlogin.login?url=");
final HtmlForm loginForm = loginPage.getFormByName("frmNIDLogin");
final HtmlTextInput idInput = loginForm.getInputByName("id");
final HtmlPasswordInput pwInput = loginForm.getInputByName("pw");
final HtmlSubmitInput loginButton = (HtmlSubmitInput) loginForm.getByXPath("//fieldset/span/input").get(0);
final String id = accountProperties.getString("username");
final String pw = accountProperties.getString("password");
if(id.equals("") || pw.equals("")){
this.logger.notice("네이버 로그인 불가: 계정 정보가 설정되어 있지 않습니다");
return;
}
idInput.setValueAttribute(id);
pwInput.setValueAttribute(pw);
Elements errors = Jsoup.parse(((HtmlPage) loginButton.click()).asXml().replaceFirst("<\\?xml version=\"1.0\" encoding=\"(.+)\"\\?>", "<!DOCTYPE html>")).select("div.error");
if(!errors.isEmpty()) this.logger.warning("네이버 로그인 실패: " + errors.text());
}catch(Exception e){
this.logger.warning("네이버 로그인 실패: " + e.getClass().getName() + ": " + e.getMessage());
}
this.close();
}
示例5: removeAd
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
private static boolean removeAd(String adId)
{
try
{
WebClient client = Client.get();
String urlDelete = LinkFactory.AD_DELETE_LINK_1 + adId;
Logger.traceINFO("URL for ad delete is : " + urlDelete);
final HtmlPage deletePage1 = client.getPage(urlDelete);
HtmlRadioButtonInput deleteRadioButton = (HtmlRadioButtonInput) deletePage1.getElementById("cmd_delete");
deleteRadioButton.setChecked(true);
HtmlSubmitInput continueButton = deletePage1.getElementByName("continue");
final HtmlPage deletePage2 = continueButton.click();
if (!deletePage2.asXml().contains("votre mot de passe tient compte des majuscules"))
{
Logger.traceERROR("Unknown error. Cannot remove ad with id : " + adId);
}
HtmlPasswordInput passwordInput = deletePage2.getElementByName("passwd");
passwordInput.setValueAttribute(DefaultUserConf.PASSWORD);
final HtmlSelect causeSelect = deletePage2.getElementByName("delete_reason");
HtmlOption autreCauseSelect = causeSelect.getOptionByValue("5");
causeSelect.setSelectedAttribute(autreCauseSelect, true);
HtmlSubmitInput continueButton2 = deletePage2.getElementByName("continue");
HtmlPage result = continueButton2.click();
return result.asXml().contains("Votre annonce sera supprim") && result.asXml().contains("lors de la prochaine mise � jour");
}
catch (Exception e)
{
Logger.traceERROR(e);
return false;
}
}
示例6: getCallbackUrl
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的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;
}
示例7: getConversation
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public static WebClient getConversation() throws IOException, SAXException {
final WebClient conversation = new WebClient();
// always login first
final Page loginPage = conversation.getPage(TestUtils.URL_ROOT
+ "login.jsp");
Assert.assertTrue("Received non-HTML response from web server", loginPage.isHtmlPage());
final HtmlPage loginHtml = (HtmlPage)loginPage;
HtmlForm form = loginHtml.getFormByName("login");
Assert.assertNotNull("Cannot find login form", form);
final HtmlTextInput userTextField = form.getInputByName("user");
userTextField.setValueAttribute(IntegrationTestUtils.TEST_USERNAME);
final HtmlPasswordInput passTextField = form.getInputByName("pass");
passTextField.setValueAttribute(IntegrationTestUtils.TEST_PASSWORD);
final HtmlSubmitInput button = form.getInputByName("submit_login");
final Page response = button.click();
final URL responseURL = response.getUrl();
final String address = responseURL.getPath();
final boolean correctAddress;
if (address.contains("login.jsp")) {
correctAddress = false;
} else {
correctAddress = true;
}
Assert.assertTrue("Unexpected URL after login: "
+ address, correctAddress);
return conversation;
}