'HtmlUnit returning empty loginForm set
I am trying to find the loginform data from the Nike website. I've added a timer to wait for the loginform to be populated but it still outputs as an empty set. I've have also tried searching for the form by name. I would appreciate any help in solving this issue. Also the code below will output warnings but it is a htmlUnit library issue, code will compile, and run
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public static void main( String[] args ) throws IOException, Exception
{
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setThrowExceptionOnScriptError(false);
HtmlPage loginPage = (HtmlPage) webClient.getPage("https://www.nike.com/login?continueUrl=https://www.nike.com/");
webClient.waitForBackgroundJavaScriptStartingBefore(6000);
System.out.println( loginPage.getForms() );
}
I've also tried to retrieve the loginForm by using this code block but been unsuccessful.
System.out.println( loginPage.getByXPath("//form[@id='nike-unite-loginform']") );
HtmlForm form = loginPage.getFormByName("nike-unite-loginForm");
List<HtmlForm> formList = (List<HtmlForm>) loginPage.getForms();
HtmlInput htmlEmail = loginPage.getElementByName("emailAddress");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
