Refine search
@Override void typeDone(final String newValue, final int newCursorPosition) { setAttribute("value", newValue); setSelectionStart(newCursorPosition); setSelectionEnd(newCursorPosition); } };
/** * {@inheritDoc} */ @Override protected void doType(final char c, final boolean shiftKey, final boolean ctrlKey, final boolean altKey) { doTypeProcessor_.doType(getValueAttribute(), getSelectionStart(), getSelectionEnd(), c, shiftKey, ctrlKey, altKey); }
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();
/** * {@inheritDoc} */ @Override public void setDefaultValue(final String defaultValue) { final boolean modifyValue = getValueAttribute().equals(getDefaultValue()); setDefaultValue(defaultValue, modifyValue); }
@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; }
public boolean Login(String user, String pass, String url) { try { final WebClient webClient = new WebClient(); // Get the first page final HtmlPage page1 = webClient.getPage(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("oauthAuthorizeForm"); final HtmlSubmitInput button = form.getInputByName("authorize"); final HtmlTextInput textField = form.getInputByName("session_login"); final HtmlPasswordInput textField2 = form.getInputByName("session_password"); // Change the value of the text field textField.setValueAttribute(user); textField2.setValueAttribute(pass); // Now submit the form by clicking the button and get back the second page. final HtmlPage page2 = button.click(); String newurl = page2.getUrl().toString(); String oauthVerifier = newurl.split("oauth_verifier=")[1].split("&")[0]; accessToken = oauthService.getOAuthAccessToken(requestToken, oauthVerifier); webClient.closeAllWindows(); logined = true; return true; } catch (Exception ex) { Logger.getLogger(ClassLinkedIn.class.getName()).log(Level.SEVERE, null, ex); } return false; }
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()); } } }
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(); }
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 }
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();
//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());
@Override protected String getCallbackUrl(final HtmlPage authorizationPage) throws Exception { HtmlForm form = authorizationPage.getFormByName("loginform"); final HtmlTextInput login = form.getInputByName("log"); login.setValueAttribute("testscribeup"); final HtmlPasswordInput passwd = form.getInputByName("pwd"); passwd.setValueAttribute("testpwdscribeup"); HtmlElement button = authorizationPage.createElement("button"); button.setAttribute("type", "submit"); form.appendChild(button); // HtmlButton button = form.getButtonByName("wp-submit"); final HtmlPage confirmPage = button.click(); form = confirmPage.getFormByName("loginform"); button = confirmPage.createElement("button"); button.setAttribute("type", "submit"); form.appendChild(button); // button = form.getButtonByName("wp-submit"); final HtmlPage callbackPage = button.click(); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
System.out.println(loginPage.getTitleText()); List<HtmlForm> forms = loginPage.getForms(); HtmlForm loginForm = forms.get(0); HtmlTextInput username = loginForm.getInputByName("Email"); HtmlPasswordInput password = loginForm.getInputByName("Passwd"); HtmlInput submit = loginForm.getInputByName("signIn"); username.setValueAttribute("username"); password.setValueAttribute("password"); HtmlPage homePage = submit.click();. Thread.sleep(10 * 1000); HtmlPage homePageFrame = (HtmlPage) homePage.getFrameByName("orkutFrame").getEnclosedPage(); HtmlPage communitiesTestPage = (HtmlPage) webClient.openWindow(new URL("http://www.orkut.co.in/Main#Community?cmm=1"), "CommunitiesWindow").getEnclosedPage(); }catch(java.security.GeneralSecurityException e) {
private void Login() throws FailingHttpStatusCodeException, MalformedURLException, IOException { WebClient client = new WebClient(); client.setJavaScriptEnabled(false); HtmlPage page = client.getPage("http://svergja.com/forum/"); HtmlForm form = (HtmlForm) page.getElementById("navbar_loginform"); HtmlTextInput username = (HtmlTextInput) page.getElementById("navbar_username"); username.setValueAttribute("stackoverflow"); HtmlPasswordInput password = (HtmlPasswordInput) page.getElementById("navbar_password"); password.setValueAttribute("stackit123"); HtmlSubmitInput button = form.getInputByValue("Log in"); page = button.click(); List<HtmlAnchor> anchorList = page.getAnchors(); for (HtmlAnchor htmlAnchor : anchorList) { if(htmlAnchor.getAttribute("href").contains("member.php?")) { page = htmlAnchor.click(); } } HtmlSpan span = (HtmlSpan) page.getElementById("userinfo"); DomNodeList<DomNode> nodeList = span.getChildNodes(); for (DomNode domNode : nodeList) { NamedNodeMap map = domNode.getAttributes(); Node node = map.getNamedItem("class"); if(node != null && node.getNodeValue() != null && node.getNodeValue().equals("usertitle")) { System.out.println("The usergroup is "+domNode.getTextContent()); } } }
System.out.println("1st page : "+page.asText()); HtmlForm form=(HtmlForm)page.getElementById("aspnetForm"); HtmlInput uName=(HtmlInput)form.getByXPath("//*[@id=\"ctl00_LoginControl_textUserName_text\"]").get(0); uName.setValueAttribute(name); HtmlInput acNo=(HtmlInput)form.getByXPath("//*[@id=\"ctl00_LoginControl_textCompanyAccount_text\"]").get(0); acNo.setValueAttribute(accountNo); HtmlPasswordInput password=(HtmlPasswordInput)form.getByXPath("//*[@id=\"ctl00_LoginControl_textPassword\"]").get(0); password.setValueAttribute(pass); HtmlSubmitInput button = (HtmlSubmitInput) form.getByXPath("//*[@id=\"ctl00_LoginControl_buttonLogin\"]").get(0); WebWindow window = page.getEnclosingWindow(); button.click(); while(window.getEnclosedPage() == page) {
@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; }
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();
webClient.waitForBackgroundJavaScript(50000); HtmlPage page1=webClient.getPage("https://www.facebook.com/bhramakarserver"); HtmlForm loginForm=(HtmlForm)page1.getElementById("login_form"); HtmlTextInput username=(HtmlTextInput)page1.getElementById("email"); HtmlPasswordInput password=(HtmlPasswordInput)page1.getElementById("pass"); username.setValueAttribute("username"); password.setValueAttribute("password"); HtmlElement button = (HtmlElement) page1.createElement("button"); button.setAttribute("type", "submit");
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();
element = new HtmlForm(namespaceURI, qualifiedName, page, attributeMap); element = new HtmlPasswordInput(namespaceURI, qualifiedName, page, attributeMap); element = new HtmlSubmitInput(namespaceURI, qualifiedName, page, attributeMap); element = new HtmlTextInput(namespaceURI, qualifiedName, page, attributeMap);