How to connect facebook php-webdriver
Maybe I'm bad looking, but I can not find any information about the use of https://github.com/facebook/php-webdriver in Mink.
There is a MinkSelenium2Driver, which relies on https://github.com/instaclick/php-webdriver/ (which forked the facebook driver at some point so they diverged a bit now)
I am concerned about the problem https://github.com/symfony/symfony/issues/11803. I used facebook/php-webdriver in CodeCeption - and there I did not face such restrictions. Or the problem of using complex CSS selectors is not related to the webdriver?
Well, Mink always does the selection by XPath in the drivers. It does not give them the CSS selectors. They are transformed earlier
What if not used transformation CSS to XPath?
I don't understand what are you proposing. If you don't want use CSS selector in this particular case, then you can do so and manually create XPATH to be used for element location.
On the contrary, I want to use a CSS selector. I want to get the items by CSS selector -n+6. But, if I understand correctly, there is a problem when transforming CSS notation to XPath. @stof, is that so? This selector has been successful in the native facebook/php-webdriver, but does not work in MinkSelenium2Driver. I 'm trying to understand what the problem..
Native web driver (facebook/php-webdriver) feds your CSS selector directly to the Selenium server and it is then used to search.
In Mink due cross-driver nature we can't use any Selenium-specific optimizations and we convert all selector types to xpath and then give xpath to the Selenium in this case.
It appears (according to your report in https://github.com/symfony/symfony/issues/11803) that transformation from CSS to xpath might be a bit incorrect resulting in xpath that haven't found anything.
Or maybe you try to find element outside the root node you're performing search upon. E.g.
<body>
<div id="one"> ... </div>
<div id="two"> <p></p> ... </div>
</body>
$session->getPage()->find('css', '#one')->find('css', 'p');
Here you want to find P in 2nd div but performing a search on first div instead.
Can you give a small testcase reproducing the issue (i.e. a small HTML file for the page, and the actions you perform on it with Mink) ?
Yes, of course) HTML:
<body>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
</ul>
</body>
Test-method implementation:
$this->visit('http://localhost/test.html');
$page = $this->getSession()->getPage();
$items = $page->findAll('css', 'li');
echo count($items); // 5
$items = $page->findAll('css', 'li:nth-child(-n+3)');
echo count($items); // 0
The following javascript code in browser console successfully executes a query:
document.querySelectorAll('li:nth-child(-n+3)').length; // 3
@Sorbing , sorry for the delay on this. Is this still happening with latest version of Selenium/WebDriver?
I wonder if that is a problem for other drivers as well.
@stof , maybe it will be good to have such test in all drivers test suite as well.