0

Attempting to use HtmlUnit. I want to input a username(pin) and password(password) and get to the next page. The output is a long list of errors.

I am unable to post all the errors. However, the majority are duplicates. I've posted below each unique error message I've received:

Sep 10, 2015 7:00:35 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'application/x-javascript'.
Sep 10, 2015 7:00:41 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/stylesheet.css' [141:2] Error in style rule. (Invalid token ".2". Was expecting one of: <S>, <LBRACE>, ".", ":", "[", <COMMA>, <HASH>, <S>.)
Sep 10, 2015 7:00:44 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/bootstrap.css' [2590:17] Error in expression; ':' found after identifier "progid".
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/style.css' [130:25] Error in expression; ':' found after identifier "data".
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/style.css' [131:8] Error in declaration. (Invalid token ",". Was expecting one of: <S>, ":".)
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/style.css' [142:17] Invalid color "#7d7e7d\0".
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/style.css' [166:23] Invalid color "#cccccc\0".
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/common/style.css' [459:17] Invalid color "#b5b5b5\0".
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.html.InputElementFactory createElementNS
INFO: Bad input type: "tel", creating a text input
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.html.InputElementFactory createElementNS
INFO: Bad input type: "url", creating a text input
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.html.InputElementFactory createElementNS
INFO: Bad input type: "email", creating a text input
Sep 10, 2015 7:00:45 PM com.gargoylesoftware.htmlunit.html.InputElementFactory createElementNS
INFO: Bad input type: "datetime", creating a text input
Sep 10, 2015 7:00:47 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://app.applyyourself.com/AYApplicantLogin/fl_ApplicantLogin.asp?id=dukegrad' [1:141] Error in declaration. '*' is not allowed as first char of a property.

I've tried using these links:

How to use HtmlUnit in Java?

Groovy htmlunit getFirstByXPath returning null + OCR Question

Here is the code:

    public ApplicationLogin(String pin, String password) throws Exception   {

    WebClient webClient = new WebClient();

    HtmlPage webPage = webClient.getPage("https://app.applyyourself.com/AYApplicantLogin/fl_ApplicantLogin.asp?id=dukegrad");
    HtmlForm form = webPage.getFirstByXPath("//form[@id='frmApplicantLogin']"); 

    HtmlTextInput username = form.getInputByName("UserID");
    HtmlPasswordInput pass = form.getInputByName("Password");

    HtmlSubmitInput b = form.getInputByValue("login");

    username.setValueAttribute(pin);
    pass.setValueAttribute(password);

    HtmlPage webPage2 = b.click();  
}
  • You can safely ignore those errors. Major errors are something like `TypeError: Cannot call method "getAttribute" of undefined`, please read http://htmlunit.sourceforge.net/submittingJSBugs.html – Ahmed Ashour Sep 10 '15 at 16:48
  • @Ahmed Are you suggesting support for the specific JavaScript library is not included yet? I'm not following what I learn from the link you listed. –  Sep 10 '15 at 17:15
  • The logs are helpful for making `perfect` websites. If something goes wrong with JavaScript, then there is probably not supported method/attribute by HtmlUnit. Please specify exactly what is wrong, and it would be helpful if you have complete case which can be checked by others, to reproduce the issue. – Ahmed Ashour Sep 10 '15 at 19:22
  • I've added all unique errors (in the edit above). If there's something else which would help in diagnosing the issue, please explain in further detail and I'll continue to edit my post. Thanks for your help. –  Sep 11 '15 at 00:17
  • These are all non-functional errors, which can be ignored, and you should be able to log in/scrape the website. – Ahmed Ashour Sep 11 '15 at 06:37

1 Answers1

0

Use another WEB driver instead of default. For instance it could be CHROME (you can chose between different browsers like CHROME, FIREFOX_31, FIREFOX_31, INTERNET_EXPLORER_8, INTERNET_EXPLORER_11 ).

WebClient webClient = new WebClient(BrowserVersion.CHROME);

I suppose it should fix your problem.

Arve
  • 8,058
  • 2
  • 22
  • 25
Taras
  • 312
  • 3
  • 7
  • I've added it. Now I get: Sep 10, 2015 11:29:50 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'application/x-javascript'. –  Sep 10 '15 at 16:31
  • It just warnings, you can ignore them – Taras Sep 11 '15 at 08:40