From: Ahmed A. <asa...@ya...> - 2017-04-19 10:00:16
|
Hi, You need to provide complete (hopefully tiny) case, so others can reproduce your issue. Please also read http://htmlunit.sourceforge.net/submittingJSBugs.html Ahmed From: jp_listero <jpl...@gm...> To: htm...@li... Sent: Tuesday, April 18, 2017 11:56 PM Subject: [Htmlunit-user] HtmlSelect doesnt trigger the events Hi there, I am building a spider for a web site that has two combo boxes, the first one populates the second one. this it is done with a java script: $('#gender').change(function () { if ($('#gender').val() == 'Female') { marital_options = ''; var selected = ''; $.each(marital_status_female, function (index, value) { if (value == 1) { selected = 'selected="selected"'; } else { selected = ''; } marital_options += '<option ' + selected + ' value="' + index + '">' + value + '</option>'; }); $('#marital_status').html('<select class="form-control" id="marital_status" name="marital_status">' + marital_options + '</select>'); this is my code try (final WebClient webClient = new WebClient(BrowserVersion.getDefault())) { webClient.setJavaScriptTimeout(5000); webClient.getOptions().setThrowExceptionOnScriptError(true); webClient.getOptions().setJavaScriptEnabled(true); webClient.waitForBackgroundJavaScript(30000); webClient.getOptions().setUseInsecureSSL(true); ... final HtmlSelect gender = page.getFirstByXPath("//*[@id=\"gender\"]"); gender.setSelectedAttribute(gender.getOptionByValue("Male"),Boolean.TRUE); final HtmlSelect marital_status = page.getFirstByXPath("//*[@id=\"marital_status\"]"); marital_status.getOptions(); // this is EMPTY Any clue how to make it works ? thank you in advance ! JP_Listero |