When i run the java code using the headless browser phatomjs ,am getting this error ,please help me to solve this ?
getting the below error
phantomjs://platform/console++.js:263 in error
Software
Jar file version:Phatomjsdriver:1.2.1
exe version:phantomjs-2.1.1-windows
IDE:Eclipse
programming language:java
code i am executing -
System.setProperty("phantomjs.binary.path", phatomPath);
ChromeOptions options = new ChromeOptions();
options.addArguments("-incognito");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new PhantomJSDriver(capabilities);
driver.get("https://www.*********.com/home.html?product=testCard");
String strPageTitle = driver.getTitle();
System.out.println("Page title: - "+strPageTitle);
WebElement nameInputField = driver.findElement(By.id("card"));
nameInputField.sendKeys("*************");
driver.findElement(By.id("go")).click();
try{
//WebDriverWait wait = new WebDriverWait(driver, 40);
//WebElement tableElement = wait.until(ExpectedConditions.elementToBeClickable(By.className("reportTable")));
WebElement tableElement = driver.findElement(By.className("reportTable"));
System.out.println("taleElemen"+tableElement);
java.util.List<WebElement> rows = tableElement.findElements(By.tagName("tr"));
for (WebElement row : rows) {
java.util.List<WebElement> cols = row.findElements(By.tagName("td"));
for (WebElement col : cols) {
testData.put(col.getText().split(":")[0],col.getText().split(":")[1]);
}
}
WebElement avlBalance = driver.findElement(By.xpath("//td[.='Available Gift Card Balance']/../td[last()]"));
testData.put("Available Gift Card Balance",avlBalance.getText());
//lstSting.add(avlBalance.getText());
}catch(Exception e){
System.out.println(e);
}
I have tried this capabilities as well -
caps = new DesiredCapabilities();
((DesiredCapabilities) caps).setJavascriptEnabled(true);
((DesiredCapabilities) caps).setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
phatomPath2
);
one more exception i am getting is -
phantomjs://platform/console++.js:263 in error
org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with class name 'reportTable'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"44","Content-Type":"application/json; charset=utf-8","Host":"localhost:4857","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_77)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"class name\",\"value\":\"reportTable\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/d8e8c560-2bb4-11e6-b5f6-ddcaaac0831c/element"}}
Command duration or timeout: 678 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
System info: host: 'IBM207-PC09G4SD', ip: '9.195.87.191', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver