Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it compatible with Selenium Webdriver 3 + geckodriver ? #427

Open
chandon opened this issue Sep 6, 2018 · 1 comment
Open

Is it compatible with Selenium Webdriver 3 + geckodriver ? #427

chandon opened this issue Sep 6, 2018 · 1 comment

Comments

@chandon
Copy link

chandon commented Sep 6, 2018

Hello,

I'm trying to make phpunt-selenium work with Selenium Webdriver 3 + Firefox + Geckodriver, is phpunit-selenium comptabile ?
php : 7.0
phpunit : 6.5.12
phpunit-selenium : 4.1.0
geckodriver : 0.19 (or 0.21)
Firefox : 57.0.4

I mange to connect Phpunit and Geckodriver/Firefox, open a page with $this->url(), but when doing $this->byCssSelector('DIV'), i got an Exception :

InvalidArgumentException: Element not found.

vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Element.php:82
vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php:136
vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php:175
vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Element/Accessor.php:72
vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:416

After investigating, (geckodriver log + var_dump in vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Element.php:82), geckodriver returns a response :

array(1) {
  'element-6066-11e4-a52e-4f735466cecf' =>string(36) "4d645ed2-8069-4fb6-9f86-e1a33311ac7b"
}

an Element.php is waiting for array["ELEMENT"]

(see mozilla/geckodriver#391)

So i think it's not compatible with geckodriver and Selenium 3 + Firefox ?

@chandon chandon changed the title Is it compatible with Selenium Webdriver 3 ? Is it compatible with Selenium Webdriver 3 + geckodriver ? Sep 6, 2018
@chandon
Copy link
Author

chandon commented Sep 6, 2018

No, it's not compatible now !

But I solved 95% of my problems by changing method fromResponseValue in Element.php. It's trying to get ELEMENT value (Selenium Format) or a key beginning with 'element' (W3C WebDriver format for geckodriver)

public static function fromResponseValue(
        array $value,
        PHPUnit_Extensions_Selenium2TestCase_URL $parentFolder,
        PHPUnit_Extensions_Selenium2TestCase_Driver $driver)
{
    $key = false;
    if (!isset($value['ELEMENT'])) {
        foreach ($value as $lKey => $val) {
            if (substr($lKey,0,7) === "element") {
                $key = $lKey;
                break;
            }
        }
        if (! $key) {
            throw new InvalidArgumentException('Element not found.');
        }
    } else {
        $key = "ELEMENT";
    }
    $url = $parentFolder->descend($value[$key]);
    return new self($driver, $url);
}

nerville added a commit to fusionforge/fusionforge that referenced this issue May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant