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

PHP Notice: Undefined index: ELEMENT error occured when I test with firefox browser #492

Closed
ghost opened this issue Oct 27, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Oct 27, 2017

I want to visit a website and input something

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

class example
{
	public function setUp()
	{	
	1	$host = 'http://localhost:4444/wd/hub'; 
	2	$capabilities = DesiredCapabilities::firefox();
	3	$driver = RemoteWebDriver::create($host, $capabilities, 5000);
	4	$driver->get('http://www.baidu.com/');
	5       $driver->findElement(WebDriverBy::id('kw'))->sendKeys('php');
	}
}

Details

When execute step 5 ,error has occur and I can't input 'php' automatically.
PHP Notice: Undefined index: ELEMENT in D:\test\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php on line 178
PHP Stack trace:
PHP 1. {main}() D:\debug\example.php:0
PHP 2. Facebook\WebDriver\example->setUp() D:\debug\example.php:20
PHP 3. Facebook\WebDriver\Remote\RemoteWebDriver->findElement() D:\debug\example.php:16

Notice: Undefined index: ELEMENT in D:\test\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php on line 178

Call Stack:
0.0002 356120 1. {main}() D:\debug\example.php:0
0.0044 641504 2. Facebook\WebDriver\example->setUp() D:\debug\example.php:20
5.9112 976680 3. Facebook\WebDriver\Remote\RemoteWebDriver->findElement() D:\debug\example.php:16

PHP Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownCommandException: POST /session/9051ba4e-2f87-4f19-b07e-467d9484d01e/element//value
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'DESKTOP-M7BARRS', ip: '192.168.1.50', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: unknown in D:\test\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:106
Stack trace:
#0 D:\test\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(9, 'POST /session/9...', Array)
#1 D:\test\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php(535): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#2 D:\test\vendor\facebook\webdriver\lib\Remote\RemoteExecuteMethod.php(40): Facebook\WebDriver\Remote\RemoteWebDriver->execute('sendKeysToEleme...', Array)
#3 D:\test\vendor\faceboo in D:\test\vendor\facebook\webdriver\lib\Exception\WebDriverException.php on line 106

Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownCommandException: POST /session/9051ba4e-2f87-4f19-b07e-467d9484d01e/element//value
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'DESKTOP-M7BARRS', ip: '192.168.1.50', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: unknown in D:\test\vendor\facebook\webdriver\lib\Exception\WebDriverException.php on line 106

Facebook\WebDriver\Exception\UnknownCommandException: POST /session/9051ba4e-2f87-4f19-b07e-467d9484d01e/element//value
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'DESKTOP-M7BARRS', ip: '192.168.1.50', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: unknown in D:\test\vendor\facebook\webdriver\lib\Exception\WebDriverException.php on line 106

Call Stack:
0.0002 356120 1. {main}() D:\debug\example.php:0
0.0044 641504 2. Facebook\WebDriver\example->setUp() D:\debug\example.php:20
5.9275 1105488 3. Facebook\WebDriver\Remote\RemoteWebElement->sendKeys() D:\debug\example.php:16
5.9280 1117880 4. Facebook\WebDriver\Remote\RemoteExecuteMethod->execute() D:\test\vendor\facebook\webdriver\lib\Remote\RemoteWebElement.php:332
5.9280 1117880 5. Facebook\WebDriver\Remote\RemoteWebDriver->execute() D:\test\vendor\facebook\webdriver\lib\Remote\RemoteExecuteMethod.php:40
5.9280 1117976 6. Facebook\WebDriver\Remote\HttpCommandExecutor->execute() D:\test\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:535
5.9374 1157488 7. Facebook\WebDriver\Exception\WebDriverException::throwException() D:\test\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:320

  • Php-webdriver version: 1.4
  • PHP version: 7.1.0
  • Selenium server version: 3.5.3
  • Operating system: windows 10
  • Browser used + version: firefox 56.0.2
@OndraM
Copy link
Collaborator

OndraM commented Oct 27, 2017

Hi, this is caused by #469 .

To solve the issue for now, you could either use Chrome (which works pretty well), or Selenium 3.4, or when using Selenium 3.5 and newer you must enable the protocol translating in Selenium (as mentioned in #469), using Selenium option -enablePassThrough false, like java -jar selenium-server-standalone-3.6.0.jar -enablePassThrough false.

Sorry for inconvenience :).

@OndraM OndraM closed this as completed Oct 27, 2017
@hermann77
Copy link

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

causes
Exception in thread "main" com.beust.jcommander.ParameterException: Was passed main parameter '-enablePassThrough' but no main parameter was defined in your arg class
at com.beust.jcommander.JCommander.initMainParameterValue(JCommander.java:936)
at com.beust.jcommander.JCommander.parseValues(JCommander.java:752)
at com.beust.jcommander.JCommander.parse(JCommander.java:340)
at com.beust.jcommander.JCommander.parse(JCommander.java:319)
at org.openqa.grid.internal.cli.StandaloneCliOptions.parse(StandaloneCliOptions.java:28)
at org.openqa.grid.selenium.GridLauncherV3$1.(GridLauncherV3.java:256)
at org.openqa.grid.selenium.GridLauncherV3.lambda$buildLaunchers$0(GridLauncherV3.java:255)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:163)
at org.openqa.grid.selenium.GridLauncherV3.launch(GridLauncherV3.java:97)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:81)

@hermann77
Copy link

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

@DanielRuf
Copy link

The passthrough option was removed in new releases. How can we solve it now?

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

3 participants