Mink icon indicating copy to clipboard operation
Mink copied to clipboard

How to connect facebook php-webdriver

Open sorbing opened this issue 11 years ago • 10 comments

Maybe I'm bad looking, but I can not find any information about the use of https://github.com/facebook/php-webdriver in Mink.

sorbing avatar Aug 29 '14 20:08 sorbing

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)

stof avatar Aug 29 '14 20:08 stof

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?

sorbing avatar Sep 02 '14 11:09 sorbing

Well, Mink always does the selection by XPath in the drivers. It does not give them the CSS selectors. They are transformed earlier

stof avatar Sep 02 '14 12:09 stof

What if not used transformation CSS to XPath?

sorbing avatar Sep 02 '14 12:09 sorbing

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.

aik099 avatar Sep 02 '14 12:09 aik099

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..

sorbing avatar Sep 02 '14 12:09 sorbing

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.

aik099 avatar Sep 02 '14 12:09 aik099

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) ?

stof avatar Sep 02 '14 13:09 stof

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 avatar Sep 02 '14 13:09 sorbing

@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.

aik099 avatar Jun 27 '15 09:06 aik099