3

So, I followed the Codeception Quick Start instructions faithfully. I run the first example test using the PhpBrowser...

# Codeception Test Suite Configuration
#
# [further comments omitted]
# 
actor: AcceptanceTester
modules:
    enabled:
        - PhpBrowser:
            url: 'http://office.localhost/'
            browser: 'firefox'
        - \Helper\Acceptance

and the test:

<?php

class FirstCest
{               
    public function frontpageWorks(AcceptanceTester $I)
    {
        $I->amOnPage('/');
        $I->see('We hope you enjoy it');

    }
}

and all is well.

Then I change the configuration to this:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'http://office.localhost/'
            browser: 'firefox'
        - \Helper\Acceptance

per the instructions, and I have Selenium installed and up and running, and away we go...

1) FirstCest: Frontpage works
 Test  tests/acceptance/FirstCest.php:frontpageWorks

  [PHPUnit\Framework\Exception] Undefined index: ELEMENT  


Scenario Steps:

 2. $I->see("InterpretersOffice") at tests/acceptance/FirstCest.php:22
 1. $I->amOnPage("/") at tests/acceptance/FirstCest.php:21

#1  /opt/www/court-interpreters-office/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:198
#2  Codeception\Module\WebDriver->see
#3  /opt/www/court-interpreters-office/tests/_support/_generated/AcceptanceTesterActions.php:363
#4  /opt/www/court-interpreters-office/tests/acceptance/FirstCest.php:22
#5  FirstCest->frontpageWorks

Selenium is driving Firefox, the page is loaded, the content that $I want to see() is there, so that ain't the problem. I have poked around in the source a bit, but haven't figured this out. I have tried changing $I->see() to $I->seeInSource() and found that does work, FWIW.

Any thoughts?

8

3 Answers 3

4

The problem is apparently that Facebook's php-webdriver isn't compatible with current Firefox.

These threads discuss the issue in more detail, and php-webdriver issue #469 tracks adding full W3C WebDriver support (which will fix the incompatibility).

A workaround is to add the -enablePassthrough false argument when launching Selenium. For example:

java -Dwebdriver.gecko.driver=./geckodriver -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false

Unfortunately, Selenium removed support for pass through mode in 3.9, so you'll have to use an older version.

Another workaround is to switch to Chrome.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this: java -jar selenium-server-standalone-3.11.0.jar -enablePassThrough false and got this error. Any other alternatives?
@Shad - Unfortunately, it looks like -enablePassThrough was removed in Selenium 3.9. See github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG.
0

In my case the only solution was:

Install chromedriver in a path that is in $PATH (/usr/bin or /bin)

and using in your test class:

$capabilities = DesiredCapabilities::chrome()

It works with executing Selenium standard way:

 java -jar selenium-server-standalone-3.14.0.jar

Comments

0

There are different situations on my Ubuntu ver. 18.x:

  1. The vendor files has been for years, I have to rm the vendor fold and rebuild it with php composer.phar require facebook/webdriver for my PHP library.

  2. The version of selenium-server-standalone-x.jar and chromedriver doesn't match. So download more version and try, finally you will get one pair to work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.