Php-webdriver: sendKeysToActiveElement UnkownCommandException only on FF and IE

Created on 13 Nov 2017  Â·  9Comments  Â·  Source: php-webdriver/php-webdriver

What are you trying to achieve? (Expected behavior)

Send keys to a text field.

What do you get instead? (Actual behavior)

PHP Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownCommandException: sendKeysToActiveElement
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'DESKTOP-NJ3HNOF', ip: '199.169.33.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: RemoteWebDriver in C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Exception\WebDriverException.php:106
Stack trace:

0 C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Remote\HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(9, 'sendKeysToActiv...', Array)

1 C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Remote\RemoteWebDriver.php(535): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))

2 C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Remo in C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Exception\WebDriverException.php on line 106

Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownCommandException: sendKeysToActiveElement
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'DESKTOP-NJ3HNOF', ip: '199.169.33.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: RemoteWebDriver in C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Exception\WebDriverException.php:106
Stack trace:

0 C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Remote\HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(9, 'sendKeysToActiv...', Array)

1 C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Remote\RemoteWebDriver.php(535): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))

2 C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Remo in C:\Users\menni\vagrant\vagrant.plinth\git\tests\tests\selenium\php-webdriver\lib\Exception\WebDriverException.php on line 106

How could the issue be reproduced? (Steps to reproduce)

$driver->getKeyboard()->sendKeys("text");

Details

I have tested my code on Chrome and Edge, and it works flawlessly, however on IE and Firefox (latest geckodriver and Firefox) I get the same error.

  • Php-webdriver version: Latest community commit as of writing.
  • PHP version: 7.1.10
  • Selenium server version: 7.1 standalone
  • Operating system: Windows 10 Creators Update
  • Browser used + version: Internet Explorer 11.674.15063.0
w3c-protocol

Most helpful comment

Filling text fields works without getKeyboard() call:

$driver
    ->findElement(WebDriverBy::id('userID'))
    ->click()
    ->sendKeys($username)
    ->sendKeys(WebDriverKeys::ENTER)
;

Geckodriver: 0.19.1
Firefox: 56.0
Selenium-Server: 3.7.1

All 9 comments

Hi, this is most probably caused by #469 . Could you try running Selenium server with -enablePassThrough false? Like this: java -jar selenium-server-standalone-3.7.0.jar -enablePassThrough false

Please let us know if it helps.

Hi, thanks for the reply. I have been running my scripts with enable
pass-through as false. Any other recommendations?

On 14 Nov 2017 00:14, "Ondřej Machulda" notifications@github.com wrote:

Hi, this is most probably caused by #469
https://github.com/facebook/php-webdriver/issues/469 . Could you try
running Selenium server with -enablePassThrough false? Like this: java
-jar selenium-server-standalone-3.7.0.jar -enablePassThrough false

Please let us know if it helps.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/facebook/php-webdriver/issues/501#issuecomment-344076974,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQpt2bGr49T_RxBcOa2utzFeYtQM_5I8ks5s2L9OgaJpZM4Qbun4
.

You can also try running it with Selenium 3.5.

I tried using IEDriver for 3.5.1 and Selenium 3.5.1 but the same issue.
I'd prefer not to use old versions of Selenium.
Surprised that no one else has encountered this issue, at least that I know of.
What else do you suggest?

No one has any solutions?

Filling text fields works without getKeyboard() call:

$driver
    ->findElement(WebDriverBy::id('userID'))
    ->click()
    ->sendKeys($username)
    ->sendKeys(WebDriverKeys::ENTER)
;

Geckodriver: 0.19.1
Firefox: 56.0
Selenium-Server: 3.7.1

@cprn
That fixed it for me. However my original problem needs to be fixed, thanks for the workaround though!

@Mennims wrote:

How are you getting your $driver instance?

This is the exact code from a working sample, obviously you don't need that much:

abstract class DriverHelper extends Helper
{
    protected $driver;

    protected function getDriver($type = 'firefox', $x = 1920, $y = 1080)
    {
        if (null === $this->driver) {
            $this->driver = RemoteWebDriver::create(
                    $this->container->getConfig('selenium')['host'],
                    $this->getCapabilities($type),
                    $this->container->getConfig('selenium')['connection_timeout_in_ms'],
                    $this->container->getConfig('selenium')['request_timeout_in_ms']
                    );
            $this->driver->manage()->window()->setSize(new WebDriverDimension($x, $y));
            $this->driver->manage()->timeouts()->implicitlyWait($this->container->getConfig('selenium')['implicit_wait_seconds']);
        }

        return $this->driver;
    }

    private function getCapabilities($context)
    {
        $capabilities = DesiredCapabilities::$context();

        switch ($context) {
            case 'firefox':
                // gets proxy from env
                $profile = new FirefoxProfile();
                $logfile = isset($_SERVER['USERPROFILE']) ? '' : '/dev/null';
                foreach (['browser', 'driver', 'profiler'] as $log_type) {
                    $profile->setPreference("webdriver.log.{$log_type}.ignore", true);
                    $profile->setPreference("webdriver.log.{$log_type}.file", $logfile);
                    $profile->setPreference("webdriver.log.{$log_type}.level", 'OFF');
                }
                $profile->setPreference('browser.download.folderList', 2);
                $profile->setPreference('browser.download.dir', 'downloads');
                $profile->setPreference('browser.helperApps.neverAsk.saveToDisk', 'application/x-octet-stream,text/csv');
                $capabilities->setCapability(FirefoxDriver::PROFILE, $profile);
                break;
            case 'phantomjs':
                // ...
                break;
        }

        return $capabilities;
    }
}

Thanks again @cprn for solving this problem for me!

Was this page helpful?
0 / 5 - 0 ratings