Further to the comments. I close the question and stop looking for strange things to do in place of of catching the exception.
HtmlUnit find the presence of a form for login
Вопрос
For doing web scraping I'm trying to figure out when I get a specific url if the loging form is present:
if(!page.getForms().isEmpty()){
HtmlForm loginForm = page.getFormByName("Valid");
if(loginForm != null){
//No valid session so login
loginForm.getInputByName("usercode").setValueAttribute("MyUser");
loginForm.getInputByName("userpwd").setValueAttribute("mypwd");
But this doesn't work because I got an exception when the form is not present. Is there a way of detecting without exception the presence of the form?
Решение
Не связан с StackOverflow