Quantcast

Re: HtmlUnit Automation Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HtmlUnit Automation Question

asashour
Hi,

You must subscribe to the list before posting.

Please provide your complete case.

Try to use htmlPage.asXml() to see what HtmlUnit actually sees, before using XPath.

Ahmed



----- Forwarded Message -----
From: "[hidden email]" <[hidden email]>
To: [hidden email]
Sent: Tuesday, April 4, 2017 7:06 PM
Subject: Auto-discard notification

The attached message has been automatically discarded.
Hi guys, I have a doubt related to an error I´m getting in an automation implementing HtmlUnit. First of all, I have to mention that I´ve tried with all of the HtmlUnit jars between 16 and 25 versions and the htmlunit-core-js 13 and 23. Now I´m going to explain my problem.
Once I login, the page brings me a form (this form with versions under 19 is empty) that has a button to submit to the dashboard page. The xml that corresponds to that button is:
 
<div style="" class="content-item content-field item-2   " string_type="field" reserve_space="false">
                                                              <div class="content-inner ">
                                                                <div class="field-item dataValueWrite">
                                                                  <span>
                                                                    <button data-test-id="20160422002653026132438" type="button" class="pzhc" data-ctl="" data-click="[[&quot;showHarnessWrapper&quot;,[&quot;newDocument&quot;,&quot;UHG-FW-SRFW-Registration&quot;,&quot;CorporateInfo&quot;,&quot;RemovePages&quot;,&quot;:&quot;,&quot;pyDisplayHarness&quot;,&quot;Search&quot;,&quot;&quot;,&quot;No&quot;,&quot;&quot;,&quot;:event&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]]]">
                                                                      <div class="pzbtn-rnd" data-click=".">
                                                                        <div class="pzbtn-lft" data-click="..">
                                                                          <div class="pzbtn-rgt" data-click="...">
                                                                            <div class="pzbtn-mid" data-click="....">
                                                                              <img src="webwb/zblankimage.gif" alt="" class="pzbtn-i"/>
                                                                              Start Here
                                                                              <img alt="" src="webwb/zblankimage.gif" class="pzbtn-i"/>
                                                                            </div>
                                                                          </div>
                                                                        </div>
                                                                      </div>
                                                                    </button>
                                                                  </span>
                                                                </div>
                                                              </div>
                                                            </div>
 
But I can´t find the way to do click on that button and submit the form.
I´ve tried with:
- obtain the page and do an executeJavaScript getting the button of the document and clicking.
- obtain the page and do an executeJavaScript getting the form and doing a submit.
- doing HtmlForm form = page.getForms().get(0) and
+ HtmlButton button = getElementByClass(‘pzhc’) and button.click()
+ HtmlButton button = form.getByXPath("//*[@id='RULE_KEY']/div/div/div/div[2]/div/div/div/div/div[2]/div/div/div/div/div[2]/div/div/span/button").get(0); (this is the Xpath of the button)
- creating a new button and adding to the form already obtained and doing click().
 
The basic problem here is that it´s having different behaviours in the browser and when I run it locally. For example, in the next image we can see the iframe with some tags inside it
 
And the results of my execution locally is this
 
<iframe name="PegaGadget0Ifr" id="PegaGadget0Ifr" border="0" frameborder="0" src="/prweb/CRExternal/ve_AdGnzk0tVEkWf1tHNZHTq26F5ROOf*/!TABTHREAD0?pyActivity=%40baseclass.doUIAction&amp;action=display&amp;harnessName=SRHome&amp;className=UHG-FW-SRFW-Registration&amp;label=Home&amp;contentID=120e5c3c-4618-4ee3-a08b-a6030e23c4f6&amp;dynamicContainerID=2cbea17f-ad84-4400-b112-2963b67d1848&amp;tabIndex=1&amp;portalThreadName=STANDARD&amp;portalName=ProviderRegistration&amp;pzHarnessID=HID4383C93F2B956C890CD840879440FB7A">
</iframe>
 
The problem is that locally is bringing me the iframe empty.
 
The main question is if anyone of you have you had this behaviuor previously.
 
Some tips to consider:
-          Depending on the version of the jar, the results of some parts like getPage or getForm are different.
-          The page is using Angular.
-          The jars between 22 to 25 is bringing me this error:
http://errors.angularjs.org/1.5.7/$rootScope/inprog?p0=%24digest (https://healthid.optum.com/tb/static/js/lib-min.js#7) of class com.gargoylesoftware.htmlunit.ScriptException where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.
RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
Rhino runtime detected object com.gargoylesoftware.htmlunit.ScriptException: Error: [$rootScope:inprog] $digest already in progress
                The jars 16 to 21 is not bringing it.
-          After every ‘getPage()’ sentence, I add this lines before continuing with the manipulation of the page
webClient.waitForBackgroundJavaScript(20000);
              webClient.waitForBackgroundJavaScriptStartingBefore(10000);
 
 
I will appreciate very much any help!

Thanks in advance,
Best regards.
Agustin.
 
 



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