From: jp_listero <jpl...@gm...> - 2017-04-18 21:56:29
|
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 |