1

I try to load the page using HtmlUnit, select the city "Белая Церковь" and see the availability of the drug in pharmacies, but even at the initial stage, when loading the page, I get an error java.util.NoSuchElementException. When I set the WebClient parameter (BrowserVersion.INTERNET_EXPLORER), then I get the page, but not completely. The HtmlUnit version is 2.48.0. Here is an example of my code, what am I doing wrong?

    try {
            WebClient client = new WebClient(BrowserVersion.CHROME);
            client.setHTMLParserListener(HTMLParserListener.LOG_REPORTER);
            client.getOptions().setJavaScriptEnabled(true);
            client.getOptions().setCssEnabled(true);
            client.getOptions().setUseInsecureSSL(true);
            client.getCookieManager().setCookiesEnabled(true);
            client.getOptions().setThrowExceptionOnScriptError(false);
            client.getOptions().setThrowExceptionOnFailingStatusCode(false);
            client.setAjaxController(new NicelyResynchronizingAjaxController());
            client.getOptions().setRedirectEnabled(true);
            client.getOptions().setGeolocationEnabled(true);

            HtmlPage page = client.getPage("https://www.aptekanizkihcen.ua/ru/ynformatsyya-o-tovare/7891");
           //HtmlTextInput townInput = (HtmlTextInput) page1.getByXPath("//input[contains(@class, 'dropdown-location-input')]").get(0);
            client.close();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
  • I have the exact same problem, on a completely different and unrelated URL. For me it works with BrowserVersion.INTERNET_EXPLORER but not with BrowserVersion.FIREFOX. I do get the page completely. – Fabian Kessler Apr 04 '21 at 04:28

0 Answers0