Re: LogIn Problems
HI,
I've found any problems in my code and now it's running.
For example for newbies(like me) the code:
final WebClient webClient = new WebClient();
webClient.setHTMLParserListener(HTMLParserListener.LOG_REPORTER);
webClient.setRedirectEnabled(true);
webClient.setJavaScriptEnabled(true);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
final URL url = new URL(Constants.BASE_URL2);
//get the LogIn-Page
final HtmlPage loginPage = (HtmlPage)webClient.getPage(url);
assertEquals("Login-Page", loginPage.getTitleText());
final HtmlForm form = loginPage.getFormByName("loginForm");
final HtmlImageInput button = (HtmlImageInput)form.getInputByName("login");
final HtmlTextInput userInput = (HtmlTextInput) form.getInputByName("username");
final HtmlPasswordInput pwdInput = (HtmlPasswordInput) form.getInputByName("password");
userInput.setValueAttribute(Constants.USER1_2);
pwdInput.setValueAttribute(Constants.PASSWD);
assertEquals( Constants.USER1_2, userInput.getValueAttribute() );
assertEquals(Constants.PASSWD, pwdInput.getValueAttribute());
assertEquals("login", button.getNameAttribute());
webClient.setRefreshHandler(new ThreadedRefreshHandler());
HtmlPage mainPage= (HtmlPage)button.click();
If there until mistakes please post it.
Regards
Daniel