1

The same action works with PhpBrowser but as soon as I set WebDriver in acceptance.suite.yml it throws the following error :

[PHPUnit\Framework\Exception] Invalid argument supplied for foreach() at vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:240

I followed the documentation for setting up WebDriver with Selenium. Here is what my acceptance.suite.yml looks like:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: '{website url here}'
            browser: chrome
        - \Helper\Acceptance
step_decorators: ~   

Here is my acceptance test file:

<?php

class FirstAcceptanceCest
{
    public function _before(AcceptanceTester $I)
    {
    }

    public function seeLoginInFrontPage(AcceptanceTester $I)
    {
        $I->amOnPage('/');
        $I->see('Login');
    }
}

Any help would be greatly appreciated.

Naktibalda
  • 13,705
  • 5
  • 35
  • 51
AdamOB
  • 13
  • 2

1 Answers1

0

Issufficient error handling in php-webdriver library again.

https://github.com/php-webdriver/php-webdriver/blob/1.13.1/lib/Remote/RemoteWebDriver.php#L228-L245

$raw_elements = $this->execute(
    DriverCommand::FIND_ELEMENTS,
    JsonWireCompat::getUsing($by, $this->isW3cCompliant)
);

if ($raw_elements === null) {
    throw new UnknownErrorException('Unexpected server response to findElements command');
}

$elements = [];
foreach ($raw_elements as $raw_element) {
    $elements[] = $this->newElement(JsonWireCompat::getElement($raw_element));
}

My debugging advice is to add

if (!is_array($raw_elements) && !is_object($raw_elements)) {
  var_dump($raw_elements); die;
}

before foreach and see if the output helps to understand the root cause.

Naktibalda
  • 13,705
  • 5
  • 35
  • 51