本文整理汇总了Java中com.gargoylesoftware.htmlunit.html.HtmlPasswordInput类的典型用法代码示例。如果您正苦于以下问题:Java HtmlPasswordInput类的具体用法?Java HtmlPasswordInput怎么用?Java HtmlPasswordInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HtmlPasswordInput类属于com.gargoylesoftware.htmlunit.html包,在下文中一共展示了HtmlPasswordInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testAdaptHtmlPasswordInputToPasswordInputElement
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
@Test
public void testAdaptHtmlPasswordInputToPasswordInputElement() throws Exception {
String elementId = getRandomChars(20);
HtmlPasswordInput htmlPasswordInput = createMock(HtmlPasswordInput.class);
HtmlPage htmlPage = createMock(HtmlPage.class);
// expect getting html element
expect(testHelperMock.getHtmlElementById(htmlPage, elementId)).andReturn(htmlPasswordInput);
// expect creating adaptor
HtmlPasswordInputToPasswordInputAdapter adapter = createMockAndExpectNew(
HtmlPasswordInputToPasswordInputAdapter.class,
htmlPasswordInput);
// perform test
replayAll();
PasswordInputElement actualPasswordInput = testSupport.getPasswordInputElementById(htmlPage, elementId);
verifyAll();
assertEquals(adapter, actualPasswordInput);
}
示例4: webFetch
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
public void webFetch(String userInput,String pwdInput) throws Exception{
final WebClient webClient=new WebClient();
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);
final HtmlPage page=webClient.getPage("https://account.xiaomi.com/pass/serviceLogin");
//��ȡ��
final HtmlForm form=(HtmlForm)page.getElementById("loginForm");
//��ȡ�ύ�ť
final HtmlSubmitInput button=form.getInputByValue("��¼");
HtmlTextInput userId=form.getInputByName("user");
HtmlPasswordInput pwd=form.getInputByName("pwd");
userId.setText(userInput);
pwd.setText(pwdInput);
final HtmlPage next=button.click();
System.out.println(next.asText());
webClient.closeAllWindows();
}
示例5: 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();
}
示例6: 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();
}
示例7: setup
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
@Before
public void setup() throws IOException {
String hostProperty = System.getProperty("jonas.host");
if (hostProperty != null) {
this.config.setHost(hostProperty);
}
String portProperty = System.getProperty("webcontainer.port");
if (portProperty != null) {
this.config.setPort(Long.parseLong(portProperty));
}
this.urlString = "http://" + config.getHost() + ":" + config.getPort()+ "/paas-portal/";
log.debug("setUp urlString=" + urlString);
final HtmlPage page = webClient.getPage(urlString);
WebAssert.assertTitleEquals(page, "GASSI - El Paaso login");
final HtmlForm form = page.getFormByName("loginform");
final HtmlSubmitInput button = form.getInputByName("submit");
final HtmlTextInput login = form.getInputByName("login");
final HtmlPasswordInput password = form.getInputByName("password");
login.setText("tescalle");
password.setText("tescalle");
home = button.click();
// TODO : uncomment when dbaas deletion will be working on env deletion
// home = webClient.getPage("http://" + host + ":" + port + "/paas-portal/app/scalability/setup");
}
示例8: 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;
}
}
示例9: findPasswordField
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
static private HtmlPasswordInput findPasswordField(HtmlPage aPage) {
HtmlPasswordInput result = null;
try {
result = aPage.getElementByName("password");
} catch (ElementNotFoundException e) {
}
return result;
}
示例10: 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;
}
示例11: getPasswordInputElementById
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
public final PasswordInputElement getPasswordInputElementById(
final HtmlPage htmlPage, final String id) {
Object element = testHelper.getHtmlElementById(htmlPage, id);
if (HTMLInputElement.class.isInstance(element)) {
return new HTMLInputToPasswordInputAdapter((HTMLInputElement) element);
} else if (HtmlPasswordInput.class.isInstance(element)) {
return new HtmlPasswordInputToPasswordInputAdapter((HtmlPasswordInput) element);
} else {
throw new ClassCastException("Unexpected class: " + element.getClass().getCanonicalName());
}
}
示例12: 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;
}
示例13: resetADPassword
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
public void resetADPassword(String user, String newPass) throws IOException {
String url = SuapConnection.SUAP_AD_RESET_PASSWD_BASE_URL + user + "/";
System.out.println("Resetando a senha para " + user);
HtmlPage pagina = conn.getPage(url);
if (pagina.getTitleText().equals(SuapConnection.SUAP_LOGIN_PAGE_TITLE)) {
pagina = login(url);
}
HtmlForm formulario = pagina.getHtmlElementById("changepassword_form");
HtmlPasswordInput senha1 = formulario.getInputByName("password");
HtmlPasswordInput senha2 = formulario.getInputByName("password_confirm");
senha1.setText(newPass);
senha2.setText(newPass);
HtmlSubmitInput sendBtn = formulario.getInputByName("changepassword_form");
sendBtn.click();
}
示例14: logon
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
/**
* Returns true if logon succeeded. False otherwise.
*
* @param aPage
* Page with login forms.
* @param app
* The app to log in to.
* @return True upon sucessful login (assumes success if it cannot find
* login forms on the page loaded after the username password
* submit).
*/
public boolean logon(HtmlPage aPage, String app) {
boolean success = false;
mNextPage = null;
HtmlTextInput userInput;
HtmlPasswordInput passInput;
HtmlSubmitInput submit;
String username, password;
// Attempt to find login forms
// If found,
// If a known site, use known information
// Try to use a list of common username and password
// try to bruteforce entry? (this should be a non-default option)
// find username, password fields, and submit button
userInput = findUsernameField(aPage);
passInput = findPasswordField(aPage);
submit = findLoginSubmitButton(aPage);
if (userInput == null || passInput == null || submit == null) {
return success; // No point in continuing if we can't find the login
// portion
}
// Determine username and password combination to use
username = determineUsername(app);
password = determinePassword(app);
userInput.setText(username);
passInput.setText(password);
// Attempt to log in.
HtmlPage newPage = null;
try {
newPage = submit.click();
} catch (IOException e) {
// FIXME what is a reasonable thing to do here?
e.printStackTrace();
}
// Verify that we are logged in. This may be done via cookies or making
// sure that we have been moved to another page (one without login
// prompts).
if (findLoginSubmitButton(newPage) == null) {
success = true;
mNextPage = newPage;
}
return success;
}
示例15: HtmlPasswordInputToPasswordInputAdapter
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入依赖的package包/类
public HtmlPasswordInputToPasswordInputAdapter(HtmlPasswordInput passwordInput) {
this.passwordInput = Validate.notNull(passwordInput);
}