@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(); }
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();
HtmlForm form = page.getFormByName("a_form"); HtmlHiddenInput formToken = form.getInputByName("form_token"); formToken.setValueAttribute("form_token_value"); /* Or without the variable: */ form.getInputByName("creation_time").setValueAttribute("creation_time_value"); HtmlSubmitInput submitInput = form.getInputByName("post"); submitInput.click();
@Test(groups = INTEGRATION) @SpecAssertion(section = CONVERSATION, id = "q") public void testEndTransientConversationThrowsException() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // try ending a transient conversation HtmlSubmitInput endConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "endConversationAndSwallowException"); page = endConversationButton.click(); assert page.getBody().getTextContent().contains("Hello world!"); }
@Test(groups = { "contexts" }) @SpecAssertion(section = "6.7.5", id = "q") public void testEndTransientConversationThrowsException() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // try ending a transient conversation HtmlSubmitInput endConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "endConversationAndSwallowException"); page = endConversationButton.click(); assert page.getBody().getTextContent().contains("Hello world!"); }
@Test @SpecAssertion(section = "6.7.5", id = "m") public void testConversationHasDefaultTimeout() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // begin a conversation HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "beginConversationButton"); page = beginConversationButton.click(); assert page.getBody().getTextContent().contains("Stratocumulus"); } }
@Test(groups = INTEGRATION) @SpecAssertion(section = CONVERSATION, id = "m") public void testConversationHasDefaultTimeout() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // begin a conversation HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "beginConversationButton"); page = beginConversationButton.click(); assert page.getBody().getTextContent().contains("Stratocumulus"); }
@Test(groups = { "contexts" }) @SpecAssertion(section = "6.7.4", id = "f") public void testConversationBeginMakesConversationLongRunning() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // begin a conversation HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "beginConversationButton"); page = beginConversationButton.click(); assert isLongRunning(page); }
@Test(groups = INTEGRATION) @SpecAssertion(section = CONVERSATION_CONTEXT_EE, id = "f") public void testConversationBeginMakesConversationLongRunning() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // begin a conversation HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "beginConversationButton"); page = beginConversationButton.click(); assert isLongRunning(page); }
@Test(groups = INTEGRATION) @SpecAssertion(section = CONVERSATION, id = "m") @SpecAssertion(section = CONVERSATION, id = "n") public void testSetConversationTimeoutOverride() throws Exception { WebClient client = new WebClient(); HtmlPage page = client.getPage(getPath("cumulus.jsf")); assert !isLongRunning(page); // begin a conversation and set a custom timeout HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "beginConversationAndSetTimeout"); page = beginConversationButton.click(); assert page.getBody().getTextContent().contains("Cumulonimbus"); }
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(); final HtmlPage page1 = webClient.getPage("http://www.facebook.com"); final HtmlForm form = page1.getFormByName("login_form"); final HtmlSubmitInput button = form.getInputsByValue("Log in"); final HtmlTextInput textField = form.getInputByName("email"); textField.setValueAttribute("jon@jon.com"); final HtmlTextInput textField = form.getInputByName("pass"); textField.setValueAttribute("ahhhh"); final HtmlPage page2 = button.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(); }
final WebClient webClient = new WebClient(); final HtmlPage page1 = webClient.getPage("http://www.facebook.com"); final HtmlForm form = page1.getFormByName("login_form"); final HtmlSubmitInput button = form.getInputsByValue("Log in"); final HtmlTextInput textField = form.getInputByName("email"); textField.setValueAttribute("youremailaddress@domain.com"); final HtmlTextInput textField = form.getInputByName("pass"); textField.setValueAttribute("yourPassword"); final HtmlPage page2 = button.click();
@Test(groups = INTEGRATION) @SpecAssertion(section = CONVERSATION_CONTEXT_EE, id = "k") public void testLongRunningConversationInstancesNotDestroyedAtRequestEnd() throws Exception { WebClient client = new WebClient(); HtmlPage storm = client.getPage(getPath("storm.jsf")); HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class, "beginConversationButton"); storm = beginConversationButton.click(); resetCloud(client); client.getPage(getPath("cloud.jsf", getCid(storm))); assert !isCloudDestroyed(client); }
@Test(groups = { "contexts"}) @SpecAssertion(section = "6.7.4", id = "k") public void testLongRunningConversationInstancesNotDestroyedAtRequestEnd() throws Exception { WebClient client = new WebClient(); HtmlPage storm = client.getPage(getPath("storm.jsf")); HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class, "beginConversationButton"); storm = beginConversationButton.click(); resetCloud(client); client.getPage(getPath("cloud.jsf", getCid(storm))); assert !isCloudDestroyed(client); }
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(); }
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 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; }