phantomjs --version.What steps will reproduce the problem?
case PhantomJSDriver:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", true);
File file = new File("//Users//denisbondya/Desktop//All Jars Repository//phantomjs-2.1.1-macosx//bin//phantomjs");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
file.getAbsolutePath());
//System.setProperty("phantomjs.binary.path", "//Users//denisbondya//Documents//workspace//V2_MainSite_SmokeAutomation//PhantomJs//phantomjs");
driver =new PhantomJSDriver(caps);
It looks like that it starts working but it doesn't see any xpath I am facing this issue:
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-03-27T15:32:19.493Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1490628739457
2.
3.
macOS Sierra
Version 10.12.3
cc @jesg
@Denchik1987 can you give the version of phantomjsdriver and selenium you are using?
example html would be helpful. do other selectors work?
My selenium version is 3.2.0 and Phantom is 2.1.1
It gives me this weird error
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-03-28T17:42:05.093Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1490722925060
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-03-28T17:42:05.887Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1490722925861
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-03-28T17:42:06.702Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1490722926651
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-03-28T17:42:07.502Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1490722927470
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-03-28T17:42:07.793Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1490722927767
FInally I came up with this code :
It starts working but I have the same problem. It says that unable to locate an element by XPATH. On Chrome, Firefox, Safari everything works just perfect. I put explicit wait, located elements by ID. This f.... ing Phantom doesn't work at all
String[] cli_args = new String[]{ "--ssl-protocol=any", "--ignore-ssl-errors=true", "--web-security=false" };
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", true);
File file = new File("//Users//denisbondya/Desktop//All Jars Repository//phantomjs-2.1.1-macosx//bin//phantomjs");
caps.setCapability( PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cli_args );
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
file.getAbsolutePath());
driver =new PhantomJSDriver(caps);
driver.manage().window().setSize(new Dimension(1280, 1024));
@Denchik1987 so locating elements by id works but locating by xpath does not work? does it also fail for expressions of the form //<tag name>[@id='<my-id>'] or //*[@id='<my-id>'].
can you provide some html here or on jsfiddle? also provide the xpath expression you are using.
Please see all my xpath below. In my tests I always find some unique div which has @id and then start initializing other elements . Everything works just fine on other browsers (Chrome, IE, Safari, Firefox) . I am just completely stuck with headless browser.
@FindBy(how=How.XPATH, using = "//div[@data-automation-id='container:category_menu']/child::a[3]")
private WebElement cartridgesDropDownHeader;
@FindBy(how=How.XPATH, using = "//div[@data-automation-id='container:category_menu']/child::a[4]")
private WebElement e_LiquidsDropDown;
@FindBy(how=How.XPATH, using = "//div[@data-automation-id='container:category_menu']/child::a[5]")
private WebElement accessoiresButtonHeader;
@FindBy(how=How.XPATH, using = "//div[@data-automation-id='container:category_menu']/child::a[6]")
private WebElement saleDropDown;
@FindBy(how=How.XPATH, using = "//div[@data-automation-id='container:category_menu']/child::a[7]")
private WebElement videosButton;
phantomjs 2.1.1 on 64bit linux //div[@data-automation-id='container:category_menu']/child::a[3] finds the element correctly. i need to check the behaviour on a mac.
does the html below look correct? do you have iframes in your html?
<html>
<head>
</head>
<body>
<div>
<div data-automation-id='container:category_menu'>
<a href='#' id=1 >1</a>
<a href='#' id=2 >2</a>
<a href='#' id=3 >3</a>
<a href='#' id=4 >4</a>
</div>
</div>
</body>
</html>
The trick is that it works fine on windows. It looks like some compatibility issues with Mac. But at my work we can't use windows.(only Mac)
Please anybody HELP!!!!!!
@Denchik1987 In case you didn't realize @jesg is trying to help you - answer the questions or provide your HTML so the issue can be reproduced - Without that there's no way to diagnose your issue.
Thank you so much. Please see a screenshot attached below. There is a unique @id for the container and then I just put slash child:: etc..

I am sorry Above one is a wrong one!!

@Denchik1987 i'm not able to reproduce the issue on a mac with the example i gave in my previous comment.
this looks like a site that is built with reactjs. are you able to provide a simple reactjs example?
Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!
Most helpful comment
@Denchik1987 In case you didn't realize @jesg is trying to help you - answer the questions or provide your HTML so the issue can be reproduced - Without that there's no way to diagnose your issue.