From: jp l. <jp....@gm...> - 2017-08-03 19:05:14
|
Hi Ronald thank you very much for your email. It was very very useful. I was blind thinking was a popup. thank you again ! On Thu, Aug 3, 2017 at 8:53 AM, Ronald Brill <rb...@rb...> wrote: > Hi jp list ;-) > > because your code is not complete and there is at least no url i can test with i have to guess a bit and i like to add some hints > > At first - the setup of your web client > Even if stackoverflow today has solutions of everything it is not always a good idea to copy that stuff without knowing what the implications of that code. > The idea of the default setup of the webclient is to configure the client as close as possible to your real browser (because HtmlUnit is designed for application testing there is one > exception of this rule regarding js error handling). > So please start without setting any option and change only the required options on demand > >> webClient.getOptions().setThrowExceptionOnScriptError(false); > This is the one exception of the general rule. But it is a good idea to do this only if you are facing js exceptions. > Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real > browsers, this might suppress some js code be required to open the popup or send the data > >> webClient.getOptions().setJavaScriptEnabled(true); > This is already the default. > >> webClient.waitForBackgroundJavaScript(30000); > As i mentioned many times on stackoverflow this is NOT an option, doing this at this place is nonsens. > >> webClient.getOptions().setActiveXNative(true); >> webClient.getOptions().setAppletEnabled(true); > Do you really need ActivX support (you are using the default browser ChromeSimulation at the moment)? > Do you really need Applet support? > >> webClient.getOptions().setCssEnabled(true); > This is already the default. > >> webClient.getOptions().setUseInsecureSSL(true); > This makes sense if you like to address application with invalid certificates. > > > Ok, so far for the setup > >><div class="bootbox modal fade in" tabindex="-1" role="dialog" >>aria-hidden="false" style="display: block; padding-right: 15px;"> >> <div class="modal-backdrop fade in" sHi there. > > Next point is your idea of an popup. You have to understand the way browsers are working. Today browsers are usually using tabs when a new 'window' gets opend. This > might be the result of anchor click with a target. Another option is the use of the javascript open funtions. > But most of the modern applications / frameworks are not doing this. They are doing some 'fake' windowing by placing some gray rectangle on top of your page and than > placing some window look alike html stuff on top of this. Your code sample looks like this solution (usually there is a lot of js/css magic behind to make this happen). > > So forget/remove the window listener stuff from your code. > The dialog is part of your current page. > > In general your code should work like that > * navigate to the start page > * locate the element that opens the dialog > * click the element to open the dialog > * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) > * locate the dialog button you like to click from the current page (looks like there is no id - you have to use XPath or iterate over all buttons on the page and select the right one > by checking for e.g. the css class and/or other attributes > * click the button > * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) > >> webClient.getOptions().setThrowExceptionOnScriptError(false); > Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real > browsers, this might suppress some js code be required to open the popup or send the data. If you have this kind of problems please open an issue. > > And as always use the latest SNAPSHOT build. > > Hope that helps, if not feel free to provide more details > > RBRi |