@Test public void submittingForm() throws Exception { final WebClient webClient = new WebClient(); // Get the first page final HtmlPage page1 = webClient.getPage("http://some_url"); // Get the form that we are dealing with and within that form, // find the submit button and the field that we want to change. final HtmlForm form = page1.getFormByName("myform"); final HtmlSubmitInput button = form.getInputByName("submitbutton"); final HtmlTextInput textField = form.getInputByName("userid"); // Change the value of the text field textField.setValueAttribute("root"); // Now submit the form by clicking the button and get back the second page. final HtmlPage page2 = button.click(); webClient.closeAllWindows(); }
/** * {@inheritDoc} */ @Override public void setText(final String text) { setValueAttribute(text); }
/** * {@inheritDoc} */ @Override public void setText(final String text) { setValueAttribute(text); }
HtmlPage currentPage = webClient.getPage("school login site"); HtmlTextInput textField2 = (HtmlTextInput) currentPage.getElementByName("j_username"); textField2.setValueAttribute(email); HtmlTextInput textField3 = (HtmlTextInput) currentPage.getElementByName("j_password"); textField3.setValueAttribute(password);
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();
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { // Get the first page final HtmlPage page1 = webClient.getPage("http://www.homedepot.ca"); // Get the form that we are dealing with and within that form, // find the submit button and the field that we want to change. final HtmlForm form = page1.getFormByName("search_terms_form"); final HtmlElement button = form.getFirstByXPath("//button[@class='search-button']"); final HtmlTextInput textField = form.getInputByName("q"); // Change the value of the text field textField.setValueAttribute("drill"); // Now submit the form by clicking the button button.click(); System.out.println(page1.getTitleText()); }
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { HtmlPage page = webClient.getPage("http://www.google.com"); HtmlAnchor a = page.getHtmlElementById("gb_70"); page = a.click(); HtmlForm form = (HtmlForm) page.getElementById("gaia_loginform"); HtmlTextInput email = (HtmlTextInput) page.getElementById("Email"); email.setValueAttribute(myEmailAddress); HtmlSubmitInput nextButton = page.getHtmlElementById("next"); System.out.println(nextButton.asXml()); HtmlPage newWebpage = nextButton.click(); String status = newWebpage.getWebResponse().getStatusMessage(); System.out.println(status); }
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();
public void submittingForm() throws Exception { WebClient webClient = new WebClient(); HtmlPage page1 = webClient.getPage("http://some_url"); HtmlForm form = page1.getFormByName("myform"); HtmlSubmitInput button = form.getInputByName("submitbutton"); HtmlTextInput textField = form.getInputByName("userid"); textField.setValueAttribute("root"); HtmlPage page2 = button.click(); }
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();
@Test public void submittingForm() throws Exception { final WebClient webClient = new WebClient(); // Get the first page final HtmlPage page1 = webClient.getPage("http://some_url"); // Get the form that we are dealing with and within that form, // find the submit button and the field that we want to change. final HtmlForm form = page1.getFormByName("myform"); final HtmlSubmitInput button = form.getInputByName("submitbutton"); final HtmlTextInput textField = form.getInputByName("userid"); // Change the value of the text field textField.setValueAttribute("root"); // Now submit the form by clicking the button and get back the second page. final HtmlPage page2 = button.click(); }
public static void main(String... args) throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page1 = webClient.getPage("http://some_url"); final HtmlForm form = page1.getFormByName("myform"); final HtmlSubmitInput button = form.getInputByName("submitbutton"); final HtmlTextInput textField = form.getInputByName("userid"); textField.setValueAttribute("root"); final HtmlPage page2 = button.click(); webClient.closeAllWindows(); }
@Test public void submittingForm() throws Exception { final WebClient webClient = new WebClient(); // Get the first page final HtmlPage page1 = webClient.getPage("http://some_url"); // Get the form that we are dealing with and within that form, // find the submit button and the field that we want to change. final HtmlForm form = page1.getFormByName("myform"); final HtmlSubmitInput button = form.getInputByName("submitbutton"); final HtmlTextInput textField = form.getInputByName("userid"); // Change the value of the text field textField.setValueAttribute("root"); // Now submit the form by clicking the button and get back the second page. final HtmlPage page2 = button.click(); webClient.closeAllWindows(); }
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 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; }
@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; }