[HtmlUnit] Running Applet using HtmlUnit?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] Running Applet using HtmlUnit?

José Lacerda
Hello,

Were you able to run the applet using HtmlUnit? How, for example?

Thank you.

--
José Lacerda
(+55) (83) 98700-5885


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Reply | Threaded
Open this post in threaded view
|

Re: [HtmlUnit] Running Applet using HtmlUnit?

Ronald Brill
You can have a look at the wetator source; check class CommandAssertApplet
in file
https://wetator.repositoryhosting.com/trac/wetator_wetator/browser/trunk/wetator/src/org/wetator/commandset/IncubatorCommandSet.java

    RBRi
    --------------------------
    WETATOR
    Smart web application testing
    http://www.wetator.org


On Mon, 13 Mar 2017 14:23:17 -0300 José Lacerda wrote:
>
>Hello,
>
>Were you able to run the applet using HtmlUnit? How, for example?
>
>Thank you.
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Reply | Threaded
Open this post in threaded view
|

Re: [HtmlUnit] Running Applet using HtmlUnit?

José Lacerda
Thank you for answer.

My Class is not get element Applet

import java.applet.Applet;
import java.io.IOException;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
import com.gargoylesoftware.htmlunit.html.HtmlApplet;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class CopyBB8HtmlUnit {

private static WebClient webClient;

public static void main(String[] args) throws Exception {
   webClient = new WebClient(BrowserVersion.FIREFOX_45);

   CookieManager cookieMan = new CookieManager();
   cookieMan = webClient.getCookieManager();
   cookieMan.setCookiesEnabled(true);
   
   webClient.setAjaxController(new NicelyResynchronizingAjaxController());
   webClient.getOptions().setJavaScriptEnabled(true);
   webClient.getOptions().setThrowExceptionOnScriptError(true);
   webClient.getOptions().setCssEnabled(true);
   webClient.getOptions().setAppletEnabled(true);
   webClient.getOptions().setPopupBlockerEnabled(false);
        
   java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
   java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF);

   HtmlPage page;
   try {
   
    System.out.println("Started");
   
       page = webClient.getPage("https://pje.tjpb.jus.br/pje2g/login.seam");

       //How get applet
       final DomNodeList<DomElement> applets = page.getElementsByTagName("assinador");
       final HtmlApplet htmlApplet = (HtmlApplet) applets.get(0);
       final Applet tmpApplet = htmlApplet.getApplet();
              
       //How set parameters
       
       //How send request
       
   } catch (IOException e) {

       e.printStackTrace();
   }

}

}



2017-03-13 14:33 GMT-03:00 Ronald Brill <[hidden email]>:
You can have a look at the wetator source; check class CommandAssertApplet
in file
https://wetator.repositoryhosting.com/trac/wetator_wetator/browser/trunk/wetator/src/org/wetator/commandset/IncubatorCommandSet.java

    RBRi
    --------------------------
    WETATOR
    Smart web application testing
    http://www.wetator.org


On Mon, 13 Mar 2017 14:23:17 -0300 José Lacerda wrote:
>
>Hello,
>
>Were you able to run the applet using HtmlUnit? How, for example?
>
>Thank you.
>




--
José Lacerda
(+55) (83) 98108-9889
(+55) (83) 98700-5885


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Reply | Threaded
Open this post in threaded view
|

Re: [HtmlUnit] Running Applet using HtmlUnit?

Ronald Brill
On Mon, 13 Mar 2017 15:42:52 -0300 José Lacerda wrote:
>
>Thank you for answer.
>
>My Class is not get element Applet
>
>public static void main(String[] args) throws Exception {
>   webClient = new WebClient(BrowserVersion.FIREFOX_45);

>   CookieManager cookieMan = new CookieManager();
>   cookieMan = webClient.getCookieManager();
>   cookieMan.setCookiesEnabled(true);

There is no need to do this CookieManager setup, this is the default


>   webClient.setAjaxController(new NicelyResynchronizingAjaxController());
>   webClient.getOptions().setJavaScriptEnabled(true);
>   webClient.getOptions().setThrowExceptionOnScriptError(true);
>   webClient.getOptions().setCssEnabled(true);
>   webClient.getOptions().setAppletEnabled(true);
>   webClient.getOptions().setPopupBlockerEnabled(false);

Same here; you only have to enable applet support

>
> java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
> java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF);

If your code does not work as expected, why the hack you disable the logging info - usually logging is done to understand the problems or find the reasons
-> http://geek-and-poke.com/geekandpoke/2016/11/27/good-questions

>   HtmlPage page;
>   try {
>
>    System.out.println("Started");
>
>       page = webClient.getPage("https://pje.tjpb.jus.br/pje2g/login.seam");
>
>       //How get applet
>       final DomNodeList<DomElement> applets = page.getElementsByTagName("assinador");
>       final HtmlApplet htmlApplet = (HtmlApplet) applets.get(0);
>       final Applet tmpApplet = htmlApplet.getApplet();

If you look at the source code of your page, the html tag with id "assinador" is not an applet tag it is an object tag instead. That is the reason why your code fails.
Bad news: Applets included via object tag are not supported at the moment by HtmlUnit.

If you need that, you can open an issue and try to motivate the developers in some way to add the support. No idea if we like to add this support because the browsers are removing the applet support step by step.
Of course you can provide a patch and we will add the support.

     RBRi
     --------------------------
     WETATOR
     Smart web application testing
     http://www.wetator.org

>
>       //How set parameters
>
>       //How send request
>
>   } catch (IOException e) {
>
>       e.printStackTrace();
>   }
>
>}
>
>}
>
>
>
>2017-03-13 14:33 GMT-03:00 Ronald Brill <[hidden email]>:
>
>> You can have a look at the wetator source; check class CommandAssertApplet
>> in file
>> https://wetator.repositoryhosting.com/trac/wetator_wetator/browser/trunk/
>> wetator/src/org/wetator/commandset/IncubatorCommandSet.java
>>
>>     RBRi
>>     --------------------------
>>     WETATOR
>>     Smart web application testing
>>     http://www.wetator.org
>>
>>
>> On Mon, 13 Mar 2017 14:23:17 -0300 José Lacerda wrote:
>> >
>> >Hello,
>> >
>> >Were you able to run the applet using HtmlUnit? How, for example?
>> >
>> >Thank you.
>> >
>>
>>
>
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Reply | Threaded
Open this post in threaded view
|

Re: [HtmlUnit] Running Applet using HtmlUnit?

José Lacerda
Hi, Ronald.

Sorry for the code. I was only evaluating the use of the tool. I got the first example I found.

Good. I know that applet has its days counted. However, this change will hardly be immediate and for many companies it will take a long time.

Many investments have been made to enable users to access the system and digitally sign documents.

In your opinion what would be the effort to accept the tag object in applet?


Thank you.

2017-03-13 16:01 GMT-03:00 Ronald Brill <[hidden email]>:
On Mon, 13 Mar 2017 15:42:52 -0300 José Lacerda wrote:
>
>Thank you for answer.
>
>My Class is not get element Applet
>
>public static void main(String[] args) throws Exception {
>   webClient = new WebClient(BrowserVersion.FIREFOX_45);

>   CookieManager cookieMan = new CookieManager();
>   cookieMan = webClient.getCookieManager();
>   cookieMan.setCookiesEnabled(true);

There is no need to do this CookieManager setup, this is the default


>   webClient.setAjaxController(new NicelyResynchronizingAjaxController());
>   webClient.getOptions().setJavaScriptEnabled(true);
>   webClient.getOptions().setThrowExceptionOnScriptError(true);
>   webClient.getOptions().setCssEnabled(true);
>   webClient.getOptions().setAppletEnabled(true);
>   webClient.getOptions().setPopupBlockerEnabled(false);

Same here; you only have to enable applet support

>
> java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
> java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF);

If your code does not work as expected, why the hack you disable the logging info - usually logging is done to understand the problems or find the reasons
-> http://geek-and-poke.com/geekandpoke/2016/11/27/good-questions

>   HtmlPage page;
>   try {
>
>    System.out.println("Started");
>
>       page = webClient.getPage("https://pje.tjpb.jus.br/pje2g/login.seam");
>
>       //How get applet
>       final DomNodeList<DomElement> applets = page.getElementsByTagName("assinador");
>       final HtmlApplet htmlApplet = (HtmlApplet) applets.get(0);
>       final Applet tmpApplet = htmlApplet.getApplet();

If you look at the source code of your page, the html tag with id "assinador" is not an applet tag it is an object tag instead. That is the reason why your code fails.
Bad news: Applets included via object tag are not supported at the moment by HtmlUnit.

If you need that, you can open an issue and try to motivate the developers in some way to add the support. No idea if we like to add this support because the browsers are removing the applet support step by step.
Of course you can provide a patch and we will add the support.

     RBRi
     --------------------------
     WETATOR
     Smart web application testing
     http://www.wetator.org

>
>       //How set parameters
>
>       //How send request
>
>   } catch (IOException e) {
>
>       e.printStackTrace();
>   }
>
>}
>
>}
>
>
>
>2017-03-13 14:33 GMT-03:00 Ronald Brill <[hidden email]>:
>
>> You can have a look at the wetator source; check class CommandAssertApplet
>> in file
>> https://wetator.repositoryhosting.com/trac/wetator_wetator/browser/trunk/
>> wetator/src/org/wetator/commandset/IncubatorCommandSet.java
>>
>>     RBRi
>>     --------------------------
>>     WETATOR
>>     Smart web application testing
>>     http://www.wetator.org
>>
>>
>> On Mon, 13 Mar 2017 14:23:17 -0300 José Lacerda wrote:
>> >
>> >Hello,
>> >
>> >Were you able to run the applet using HtmlUnit? How, for example?
>> >
>> >Thank you.
>> >
>>
>>
>
>




--
José Lacerda
(+55) (83) 98108-9889
(+55) (83) 98700-5885


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Reply | Threaded
Open this post in threaded view
|

Re: [HtmlUnit] Running Applet using HtmlUnit?

Ronald Brill
Hi Jose

>Sorry for the code. I was only evaluating the use of the tool. I got the
>first example I found.

No problem in the end it is your code ;-)


>Good. I know that applet has its days counted. However, this change will
>hardly be immediate and for many companies it will take a long time.
>
>Many investments have been made to enable users to access the system and
>digitally sign documents.

Yes, i fear you are right.

>In your opinion what would be the effort to accept the tag object in applet?

This depends on your expectations:
- adding an getApplet() method to the object tag that returns an applet if the content type is 'application/x-java-applet' will be more or less simple. Of course there is no support for different JDK
versions, we will only use the JDK that runs HtmlUnit itself.
- next step will be any interaction with that applet - i have no idea if you need this (like pressing some buttons etc). I think this is your part; means you program gets the Applet instance from
HtmlUnit and the rest is up to you
- and finally your applet has some forward reference to js functions. The stubs are there but this was never implemented for the applet support. If this is required, this will be a bit more work because
we might write some test applets also.

In the simplest case maybe 1 day and for the whole story 1 week.


        RBRi


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Reply | Threaded
Open this post in threaded view
|

Re: [HtmlUnit] Running Applet using HtmlUnit?

José Lacerda
Ronald,

- adding an getApplet() method to the object tag that returns an applet if the content type is 'application/x-java-applet' will be more or less simple. Of course there is no support for different JDK versions, we will only use the JDK that runs HtmlUnit itself.
Very good.

- next step will be any interaction with that applet - i have no idea if you need this (like pressing some buttons etc). I think this is your part; means you program gets the Applet instance from HtmlUnit and the rest is up to you
In the application when I click to Access with Digital Certificate, it opens the popup to select the certificate and click OK. Then, it opens a screen to enter the password. These steps are performed locally, that is, without traffic on the network. After the password is OK the post is done.

- and finally your applet has some forward reference to js functions. The stubs are there but this was never implemented for the applet support. If this is required, this will be a bit more work because we might write some test applets also.
From what I can see, it uses three JS functions. (=

I have already tested five tools and none functional for the entire scope. The best I've found so far is HtmlUnit. The steps after login were successful. Just missing the applet. I'm a little worried.

What depends on me to get the job done?

2017-03-15 16:05 GMT-03:00 Ronald Brill <[hidden email]>:
Hi Jose

>Sorry for the code. I was only evaluating the use of the tool. I got the
>first example I found.

No problem in the end it is your code ;-)


>Good. I know that applet has its days counted. However, this change will
>hardly be immediate and for many companies it will take a long time.
>
>Many investments have been made to enable users to access the system and
>digitally sign documents.

Yes, i fear you are right.

>In your opinion what would be the effort to accept the tag object in applet?

This depends on your expectations:
- adding an getApplet() method to the object tag that returns an applet if the content type is 'application/x-java-applet' will be more or less simple. Of course there is no support for different JDK
versions, we will only use the JDK that runs HtmlUnit itself.
- next step will be any interaction with that applet - i have no idea if you need this (like pressing some buttons etc). I think this is your part; means you program gets the Applet instance from
HtmlUnit and the rest is up to you
- and finally your applet has some forward reference to js functions. The stubs are there but this was never implemented for the applet support. If this is required, this will be a bit more work because
we might write some test applets also.

In the simplest case maybe 1 day and for the whole story 1 week.


        RBRi




--
José Lacerda
(+55) (83) 98108-9889
(+55) (83) 98700-5885


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop