I am performing some test on a website, which is referring to a javascript array _gaq
and it is not defined anywhere in the page. I can see the similar exception in Browser but there it is ignoring it. I set the method setThrowExceptionOnScriptError(false)
but still it is throwing
com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "_gaq" is not defined.
Below is my code
WebClient wb = new WebClient(BrowserVersion.CHROME);
wb.getOptions().setThrowExceptionOnScriptError(false);
page = wb.getPage("http://www.axisbank.com/");
HtmlElement el = ((HtmlElement)(page.getByXPath("//*[@id=\"form1\"]/div[5]/div[2]/div[3]/div/div[5]/img").get(0)));
page = el.click();
el = ((HtmlElement)(page.getByXPath("//*[@id=\"ContentPlaceHolder1_btnLogin\"]").get(0)));
System.out.println(el.asText());
page = el.click();
Any suggestion how to solve this problem. I tried adding page.executeScript("var _gaq = []")
, but still failing