LifelongTundra · GitHub

I am attempting to click on a bar that expands and gives extra search options. The site is https://www.j-platpat.inpit.go.jp/?uri=/t0100. The other buttons/bars work when clicked as demoed by the English button in this snippet, but in the full code for this program I have tested both the search button and the Exclusion Keywords bar and both work. I assume this is a Java Script issue as soon as the program clicks the button it gives these messages.

INFO: @https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 be()@https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 Ye()@https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 @https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 qu()@https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 ya()@https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 @https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 @https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 La()@https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1 Ku()@https://www.j-platpat.inpit.go.jp:443/main.9feec0b83f1ac2f1c55e.bundle.js:1

I know these messages come up when the button is clicked by adding in a Thread.sleep() before and after the click to see when it happens. Again I'm not positive why this is the only Java Script to not work on this page, but I am unsure of how to approach this problem.

Here is the code snippet:

import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class Error
{
  public static void main(String[] args) throws Exception
  {
    WebClient webClient = new WebClient(BrowserVersion.CHROME);
    webClient.getOptions().setJavaScriptEnabled(true);
    webClient.getOptions().setCssEnabled(false);
    webClient.getOptions().setUseInsecureSSL(false);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    HtmlPage startPage = webClient.getPage("https://www.j-platpat.inpit.go.jp/?uri=/t0100");
    webClient.waitForBackgroundJavaScriptStartingBefore(10000);
    /**
     * Changes page to English
     */
    HtmlElement english = (HtmlElement) startPage.getElementById("cfc001_header_lnkLangChange");
    english.click();
    /**
     * This button is used to get other search options so you could search by filling date.
     * Unfortunately, whenever I attempted to press the button the page would crash.
     */
    HtmlElement extraSettings = (HtmlElement) startPage
        .getElementById("t01_srchOption_title_searchOptn");
    extraSettings.click();
    System.out.println(startPage.asText());
  }
}

Read the original on github.com ↗