/** * {@inheritDoc} */ @Override public void setText(final String text) { setValueAttribute(text); }
/** * {@inheritDoc} */ @Override public void setText(final String text) { setValueAttribute(text); }
HtmlTextInput email = (HtmlTextInput)page.getElementById("Email"); email.setValueAttribute(emailAddress); HtmlPasswordInput passwd = (HtmlPasswordInput)page.getElementById("Passwd"); passwd.setValueAttribute(password); HtmlSubmitInput signInButton = (HtmlSubmitInput)page.getElementById("signIn"); webClient.waitForBackgroundJavaScriptStartingBefore(8000); HtmlPage newPage = (HtmlPage)signInButton.click();
public class FormSubmit { public static void main(String[] args) throws Exception { try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { final HtmlPage page1 = webClient.getPage("https://applicazioni.gse.it/GWA_UI/"); System.out.println(page1.asXml()); final HtmlForm form = page1.getFormByName("aspnetForm"); final HtmlTextInput username = form.getInputByName("ctl00$ctl00$cphFormAppl$cphRisultatiRicerca$txtUserid"); username.setValueAttribute("namevalue"); final HtmlPasswordInput password = form.getInputByName("ctl00$ctl00$cphFormAppl$cphRisultatiRicerca$txtPassword"); password.setValueAttribute("passvalue"); final HtmlPage page2 = (HtmlPage) form.getInputByValue(" Login ").click(); System.out.println(page2.asText()); } } }
HtmlPage page3; page3 = webClient.getPage("Website"); HtmlForm loginForm = page3.getFormByName("loginForm"); HtmlTextInput username = loginForm.getInputByName("NameofUsernameElement"); HtmlPasswordInput pass = loginForm.getInputByName("NameofPassowordElement"); HtmlSubmitInput b = loginForm.getInputByValue("LoginButtonValue"); username.setValueAttribute("Actualy Username"); pass.setValueAttribute("Actual Password"); HtmlPage page2; page2 = b.click();
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6); webClient.setJavaScriptEnabled(true); webClient.getCookieManager().setCookiesEnabled(true); try{ final HtmlPage page1 = webClient.getPage("http://www.ccstechnologies.org/login.aspx/"); final HtmlForm form = page1.getFormByName("form1"); final HtmlSubmitInput button = form.getInputByName("BtnLogin"); final HtmlTextInput textField = form.getInputByName("Username"); final HtmlPasswordInput pwd = form.getInputByName("password"); textField.setValueAttribute("username"); pwd.setValueAttribute("password"); System.out.println(page1.asText()); final HtmlPage page2 = (HtmlPage) form.getInputByValue("Login").click(); String htmlBody = page2.getWebResponse().getContentAsString(); System.out.println(page2.asText()); System.out.println("Base Uri 1 : "+page1); System.out.println("Base Uri 2 : "+page2); webClient.closeAllWindows();}catch (Exception e) { // TODO: handle exception }
WebClient client = new WebClient(BrowserVersion.CHROME); client.getOptions().setJavaScriptEnabled(true); client.getOptions().setThrowExceptionOnScriptError(false); client.getOptions().setThrowExceptionOnFailingStatusCode(false); HtmlPage page = client.getPage("http://yoursite.com/"); HtmlTextInput user = page.getElementByName("USER_ID"); user.setValueAttribute("youruser"); HtmlPasswordInput password = page.getElementByName("PWD"); password.setValueAttribute("yourpassword"); HtmlButtonInput loginButton = (HtmlButtonInput) page.getByXPath("//input[@class='loginbtn']").get(0); page = loginButton.click(); System.out.println(page.asText()); client.close();
//Get Page HtmlPage page1 = webClient.getPage("https://login-url/"); //Wait for background Javascript webClient.waitForBackgroundJavaScript(10000); //Get first form on page HtmlForm form = page1.getForms().get(0); //Get login input fields using input field name HtmlTextInput userName = form.getInputByName("UserName"); HtmlPasswordInput password = form.getInputByName("Password"); //Set input values userName.setValueAttribute("MyUserName"); password.setValueAttribute("MyPassword"); //Find the first button in form using name, id or xpath HtmlElement button = (HtmlElement) form.getFirstByXPath("//button"); //Post by clicking the button and cast the result, login arrival url, to a new page and repeat what you did with page1 or something else :) HtmlPage page2 = (HtmlPage) button.click(); //Profit System.out.println(page2.asXml());
//set browser WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10); //not to throw exception on javascript error webClient.setThrowExceptionOnScriptError(false); //set page to access final HtmlPage homepageEn = webClient.getPage("http://protein.rnet.missouri.edu:8080/MongoTest/"); //get the form by id HtmlForm form = homepageEn.getFirstByXPath("//form[@id='input_form']"); //setup the fields to use HtmlTextInput mailField = form.getInputByName("mail"); HtmlPasswordInput passwordField = form.getInputByName("password"); //define the submit button (defined by value) HtmlSubmitInput submitButton = form.getInputByValue("submit"); //change the value of text fields mailField.setValueAttribute("somemail@xyzmail.com"); passwordField.setValueAttribute("some_password"); //finally submit the form by clicking the button final HtmlPage resultsPage = submitButton.click();
try { String url = "https://www.linkedin.com/uas/login?goback=&trk=hb_signin"; final WebClient webClient = new WebClient(); webClient.getOptions().setJavaScriptEnabled(false); webClient.getOptions().setCssEnabled(false); final HtmlPage loginPage = webClient.getPage(url); //Get Form By name final HtmlForm loginForm = loginPage.getFormByName("login"); final HtmlSubmitInput button = loginForm.getInputByName("signin"); final HtmlTextInput usernameTextField = loginForm.getInputByName("session_key"); final HtmlPasswordInput passwordTextField = loginForm.getInputByName("session_password"); usernameTextField.setValueAttribute(userName);//your Linkedin Username passwordTextField.setValueAttribute(password);//Your Linkedin Password final HtmlPage responsePage = button.click(); String htmlBody = responsePage.getWebResponse().getContentAsString(); System.out.println(htmlBody); } catch (Exception ex) { ex.printStackTrace(); }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { final HtmlForm form = authorizationPage.getForms().get(0); final HtmlTextInput login = form.getInputByName("login"); login.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput password = form.getInputByName("password"); password.setValueAttribute("testpwdscribeup1"); final HtmlSubmitInput submit = form.getInputByName("commit"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { final HtmlForm form = authorizationPage.getForms().get(0); final HtmlTextInput email = form.getInputByName("Email"); email.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput passwd = form.getInputByName("Passwd"); passwd.setValueAttribute("testpwdscribeup34"); final HtmlSubmitInput submit = form.getInputByName("signIn"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
final WebClient webClient = new WebClient(); final HtmlPage page1 = webClient.getPage("http://www.facebook.com"); final HtmlForm form = (HtmlForm) page1.getElementById("login_form"); final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Log In").get(0); final HtmlTextInput textField = form.getInputByName("email"); textField.setValueAttribute("jon@jon.com"); final HtmlPasswordInput textField2 = form.getInputByName("pass"); textField2.setValueAttribute("ahhhh"); final HtmlPage page2 = button.click();
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { final HtmlTextInput login = authorizationPage.getElementByName("login"); login.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput password = authorizationPage.getElementByName("passwd"); password.setValueAttribute("testpwdscribeup"); final HtmlSubmitInput submit = authorizationPage.getElementByName("SI"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { final HtmlForm form = authorizationPage.getForms().get(0); final HtmlTextInput sessionUsernameOrEmail = form.getInputByName("session[username_or_email]"); sessionUsernameOrEmail.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput sessionPassword = form.getInputByName("session[password]"); sessionPassword.setValueAttribute("testpwdscribeup"); final HtmlSubmitInput submit = form.getElementById("allow"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { final HtmlForm form = authorizationPage.getForms().get(0); final HtmlTextInput email = form.getInputByName("email"); email.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput password = form.getInputByName("pass"); password.setValueAttribute("testpwdscribeup"); final HtmlSubmitInput submit = form.getInputByName("login"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { final HtmlForm form = authorizationPage.getFormByName("oauthAuthorizeForm"); final HtmlTextInput sessionKey = form.getInputByName("session_key"); sessionKey.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput sessionPassword = form.getInputByName("session_password"); sessionPassword.setValueAttribute("testpwdscribeup"); final HtmlSubmitInput submit = form.getInputByName("authorize"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { HtmlForm form = authorizationPage.getForms().get(0); final HtmlTextInput email = form.getInputByName("Email"); email.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput passwd = form.getInputByName("Passwd"); passwd.setValueAttribute("testpwdscribeup34"); HtmlSubmitInput submit = form.getInputByName("signIn"); final HtmlPage confirmPage = submit.click(); form = confirmPage.getForms().get(0); submit = form.getInputByName("allow"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { HtmlForm form = authorizationPage.getForms().get(1); final HtmlTextInput login = form.getInputByName("login_email"); login.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput passwd = form.getInputByName("login_password"); passwd.setValueAttribute("testpwdscribeup"); HtmlSubmitInput submit = form.getInputByName("login_submit_dummy"); final HtmlPage confirmPage = submit.click(); form = confirmPage.getForms().get(1); submit = form.getInputByName("allow_access"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { HtmlForm form = authorizationPage.getFormByName("login_form"); final HtmlTextInput login = form.getInputByName("login"); login.setValueAttribute("testscribeup@yahoo.fr"); final HtmlPasswordInput passwd = form.getInputByName("passwd"); passwd.setValueAttribute("testpwdscribeup"); HtmlSubmitInput submit = form.getInputByName(".save"); final HtmlPage confirmPage = submit.click(); form = confirmPage.getFormByName("rcForm"); submit = form.getInputByName("agree"); final HtmlPage callbackPage = submit.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }