0

I am trying to login into the yahoo mail with jaunt-api but getting "cookie not enabled issue". I am new in jaunt-api, so please help me. I am using the following code.

try
{
UserAgent userAgent = new UserAgent();
            userAgent.setCacheEnabled(false);
            userAgent.settings.autoSaveAsHTML = true;
            try{
                userAgent.cookieJar.saveCookies(new File("e:\\cookie.txt"));
            }catch(Exception e){}
            userAgent.visit("https://login.yahoo.com/m");                        

            try{
            userAgent.cookieJar.loadCookies(new File("e:\\cookie.txt"));
            }catch(Exception e){}

            Form form = userAgent.doc.getForm(0);
            form.setTextField("username", "*****@gmail.com");
            form.setPassword("passwd", "*******");
            form.submit();
            System.out.println(userAgent.doc.innerHTML());
            System.out.println(userAgent.getLocation());
        }catch(JauntException e){
            System.out.println(e);
        }
leppie
  • 115,091
  • 17
  • 196
  • 297
Ravi Kumar
  • 432
  • 4
  • 14

1 Answers1

0

Cookies cannot be loaded into Jaunt from a text file, you need to specify the same file that you previously used for saving cookies. (Jaunt is serializing the cookies container object, so unless that's the content of the .txt file, it's not going to work).