How to configure Eclipse with Web driver PHP Binding and selenium stand alone server

1,152 views
Skip to first unread message

Neil Anderssion

unread,
Mar 8, 2013, 12:56:49 AM3/8/13
to seleniu...@googlegroups.com

I am getting lots of instruction material related to "how to configure eclipse for java and selenium" ,

But my requirement is i want to use eclipse for PHP and i want to connect it with selenium stand alone server and  webdriver  php  framework  , so that i can run my selenium test cases from eclipse.

i have already installed XAMPP , PHPUNIT. i have already downloaded selenium stand alone server and Eclipse for php .

can any one please suggest how to do that.

David

unread,
Mar 8, 2013, 2:56:39 AM3/8/13
to seleniu...@googlegroups.com
You just need to configure how to run PHPUnit from Eclipse. Perhaps Google for that.

Basically, it's not built in like for Java, so you can't use the default Run/Run As option. You have to go configure external tools section and then run external tool to run PHPUnit.

Run->External tools->open External Tools Configuration

add new configuration entry for PHPUnit

specify path to PHPUnit (for Windows is the batch file for Linux/Mac is the PHPUnit binary itself) for location field

working directory = ${workspace_loc}

arguments = ${resource_path}

in Mac however, I did things a little differently because there's no batch file to run PHPUnit:

location = /usr/bin/php

and arguments = /usr/bin/phpunit --include-path "${project_loc}" ${resource_path} 

then to run test, select file in the (file) explorer window/view in Eclipse, then click menu option 

run->external tools->PHPUnit, assuming you named the external tool entry "PHPUnit".

The results should show in the Eclipse console view, etc.

But I would note that I personally find executing tests via the batch file in a terminal command line window more useful for analyzing results than to view it in the Eclipse console. It runs faster outside of Eclipse. But those are the steps above to run in Eclipse.

If you have Selenium server already running & PHPUnit Selenium framework code all set up, then things will run fine.

Neil Anderssion

unread,
Mar 8, 2013, 5:32:27 AM3/8/13
to seleniu...@googlegroups.com

Hi david


Thank you for your reply, 


I  have installed  Eclipse in  D: drive 

D:\eclipse

i am have installed Xampp and in Xampp i have installed PHPUNIT ,PEAR etc

 Xampp location is  D:\xampp\

 Php is under Xampp so  php location is : D:\xampp\php\

 PEAR is under php  so PEAR location is D:\xampp\php\PEAR\

 PHPUNIT is under PEAR  so PHPUNIT  location is  D:\xampp\php\PEAR\PHPUnit



previously what ever code i have written is stored under  "www"  folder which is under "php" folder

so all test case file location is  for example  D:\xampp\php\www\search.php 


I have stored php web driver binding under the "www" folder also

location : D:\xampp\php\www\phpwebdriver


During selenium configuration i have selected the workspace " Selenium testcase"
which is also under the "www" folder 

location : D:\xampp\php\www\Selenium testcase


david can u u tell me what should i write in the 

working directory  and arguments field ? i have tried with ${workspace_loc} and ${resource_path} respectively for those fields but it is not working. 

After starting the selenium stand alone server when i tried to run my php code  it is not working , the message is showing " not able to open the php file" 

can u please help what wrong i have done in configuration , what changes i need to make .


i have tried to install Xdebugg but according to xdebugg they required higher version of PHP engine but the latest xampp has the lower version comparison to their requirement , so i am not able to install Xdebugg.














--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/EcYmfAJ4raY/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/EQGZ8yOCuTgJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Neil Anderssion

unread,
Mar 8, 2013, 5:41:24 AM3/8/13
to seleniu...@googlegroups.com
Hi david  i  have written one wrong line


" During selenium configuration i have selected the workspace " Selenium testcase"
which is also under the "www" folder  "        this line is written wrongly


it will be  During Eclipse configuration i have selected the workspace " Selenium testcase"
which is also under the "www" folde
 
location : D:\xampp\php\www\Selenium testcase




David

unread,
Mar 10, 2013, 1:47:05 AM3/10/13
to seleniu...@googlegroups.com
Neil,

Not sure if you read my post correctly or got confused. Based on your setup, then this is how I think you should configure Eclipse:

location = D:\xampp\php\phpunit.bat
workspace = D:\xampp\php\www\folderToPhpTestsToRun OR ${workspace_loc}
arguments = ${resource_path}

Here's how the 3 parameters are supposed to be defined above

location = path to PHPUnit. On Windows, you typically execute PHPUnit via the phpunit.bat batch file. So you first must find where that is. And then put that as location value. I used WAMP instead of XAMPP and based on how my WAMP was structured, I assume the path I gave above should be correct for you. Because for me I have:

"C:\wamp\bin\php\php5.3.0\php.exe"
"C:\wamp\bin\php\php5.3.0\phpunit" //the binary but not .exe file must run via phpunit.bat
"C:\wamp\bin\php\php5.3.0\phpunit.bat"
"C:\wamp\bin\php\php5.3.0\PEAR\PHPUnit" //support files for phpunit

and the content of PHPUnit looks like

set PHPBIN="C:\wamp\bin\php\php5.3.0\php.exe"
%PHPBIN% "C:\wamp\bin\php\php5.3.0\phpunit" %*

So you execute PHPUnit as follows: phpunit.bat C:\pathTo\mytest.php

If you don't have a phpunit.bat, you might want to make one. Otherwise, your location variable might look like:

D:\xampp\php\php.exe D:\xampp\php\phpunit

or just

D:\xampp\php\php.exe

and then have argument =

D:\xampp\php\phpunit ${resource_path}

workspace = working directory (typically within Eclipse). If you're using the Eclipse workspace (i.e. D:\xampp\php\www\folderToPhpTestsToRun is actually your Eclipse workspace or opened in Eclipse) then you can simply use the variable ${workspace_loc} or one of the other variables otherwise, you'd have to hard code the specific directory.

arguments = what you pass to PHPUnit as argument. You can't hard code this, because you'd be running different tests or test suites (unless you always just run the same test suite). So argument will be typically the file you select (i.e. highlight in "file" tree explorer/view of Eclipse) before running the external tool command. You get the value of this argument via ${resource_path} variable.

Hope this helps clarify things. As you've elaborated your file setup. You might want to clarify how you set up your Eclipse workspace in case things still don't work.

Neil Anderssion

unread,
Mar 12, 2013, 3:07:47 AM3/12/13
to seleniu...@googlegroups.com
Hi david


I  have changed in the  configuration.

During launching the Eclipse i selected the the work space location   D:\xampp\php\www\First Project

Under the " First Project" folder i have created a php file [ search.php]  , and   from "run"->run configuration tab  i have selected  the "project default " option for  "Runtime PHP" field. [ screenshot: run_configuration.png] and the problem which is happening is [ run_config_problem.png]

For during external tool configuration  i have given  

location = D:\xampp\php\phpunit.bat
workspace = D:\xampp\php\www\First Project
arguments = ${resource_path}


screenshot : eclipse_external_tool_config.png  and the problem which was happened  [ eclipse_config_problem_launching.png]

When i tried to lunch the external tool after setup  once it show the error "variable resource empty" and another time  it show the error "php.exe  not executrable file"

i have attached the screenshot , please check it once,



Regards
Neil




To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/fNYqSFIA_cMJ.
eclipse_config_problem_launching.png
eclipse_external_tool_config.png
run_config_problem.png
run_configuration.png

David

unread,
Mar 12, 2013, 7:49:17 PM3/12/13
to seleniu...@googlegroups.com
Neil, you don't have to configure "run configuration". I didn't have to do that to get things working. You just need to configure external tool configuration.

The location, set to php.bat file and the php.bat file containing the command and path to php.exe will take care of making sure PHP path is set up. That means, if you can run a PHP test by running "D:\xampp\php\phpunit.bat D:\xampp\php\www\First Project\search.php" from command line, then your setup is ok, and should run from Eclipse too.

The reason it fails with "variable resource empty" is because you didn't select the search.php file. You have to click it then go to (click) run external tool config named "phpunit".

Also, you should add the external tool config named "phpunit" to the external tools menu. Do so via the external tools config dialog, Common tab > Display in favorites menu > External Tools. Then phpunit should show up in the external tools drop down menu for easy clicking to execute.

For your other issue, not sure, but probably caused by your configuring a "run configuration" for PHP. I recommend you remove it. That should take away the error I think.

Funny I'm the only one providing help to you here. So wondering what the other Selenium PHP users use for an IDE. Or maybe those users are not on this group...

Neil Anderssion

unread,
Mar 13, 2013, 5:15:02 AM3/13/13
to seleniu...@googlegroups.com
Hi
David

i removed the run configuration . and to do everything from start i removed the folder "First Project" also which i created to store php file.

i open the eclipse selected the workspace : D:\xampp\php\www\

Now  from eclipse  " File->Php Project" i created a new project called " demoproject"  [ D:\xampp\php\www\demoproject] under demoproject i put the "phpwebdriver" folder also[  i.e the binding which i am using] , now i created a phpfile called "search.php" under the project "demoproject".

After doing all the above stuffs , i selected the "search.php" from the left panel and then go to the external tool configuration section [ see the  screenshot "external_config.png " ]  after configure when i run it it is showing the error 

[ '".\php.exe"' is not recognized as an internal or external command, operable program or batch file. ]  ,see the screenshot [ external_config_problem.png ]

But at command prompt , when i  gave   "D:\xampp\php\phpunit.bat D:\xampp\php\www\demoproject\search.php"  it is working fine, that is opening firefox browser and doing the operations as written in code. [ see the screenshot : command_prompt_its_working.png ]

As u have suggested that if it run from command prompt then it should also run from eclipse , but  it is not happening here.

can u suggest what type of modification i required , so that it can run from eclipse.

Regards
Neil






To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Dj2w9oWZJn4J.
command_prompt_its_working.png
external_config.png
external_config_problem.png

David

unread,
Mar 14, 2013, 1:30:13 AM3/14/13
to seleniu...@googlegroups.com
Try changing the working directory to ${workspace_loc} to see if that helps. Your config looks fine otherwise.

Neil Anderssion

unread,
Mar 14, 2013, 5:09:25 AM3/14/13
to seleniu...@googlegroups.com
Hi David


I have tried  by setting  working directory to ${workspace_loc} but still the same error is showing  '".\php.exe"' is not recognized as an internal or external command, operable program or batch file. ].

Regards
Neil





To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/MYHLdKZ2wHgJ.

Neil Anderssion

unread,
Mar 19, 2013, 4:57:22 AM3/19/13
to seleniu...@googlegroups.com, David Luu
Hi David


i have removed the REM comment , now my phunit.bat file looks like this


set PHPBIN=.\php.exe
"%PHPBIN%" "D:\xampp\php\phpunit" %*


as i have stated earlier  that  i have created a "demoproject" folder under "www" folder

file structure  D:\xampp\php\www\demoproject

i have found 2 interesting thing , i hope this two information may lead us to the solution.


1) when through command prompt i tried to run the search.php file which is under demoproject through the below command

D:\xampp\php\phpunit.bat D:\xampp\php\www\demoproject\search.php

after typing the above command it is processing like this

D:\xampp\php>SET PHPBIN=.\php.exe

D:\xampp\php>".\php.exe" "D:\xampp\php\phpunit" D:\xampp\php\www\demoproject\search.php

then it executes as per the code


But when in eclipse after configuring the external tool , i click on the Run button it proceeds like the following

D:\xampp\php\www\demoproject>".\php.exe" "D:\xampp\php\phpunit" \demoproject\search.php 

'".\php.exe"' is not recognized as an internal or external command,
operable program or batch file.


As per my observation , in eclipse it is showing error because it is trying search  .\php.exe  , in the D:\xampp\php\www\demoproject  folder, and that's why it is returning an error .


I have attached the screenshot for better understanding, please find the attachment.





command_prompt.png
Eclipse_error.png

Neil Anderssion

unread,
Mar 19, 2013, 5:09:21 AM3/19/13
to seleniu...@googlegroups.com, David Luu
Hi
david


For better under standing i am  pasting the phpunit.bat file original content and content after modification


*************************************************************ORIGINAL phpunit.bat file content start*************************************************************************

@echo off
REM PHPUnit
REM
REM Copyright (c) 2002-2010, Sebastian Bergmann <seba...@phpunit.de>.
REM All rights reserved.
REM
REM Redistribution and use in source and binary forms, with or without
REM modification, are permitted provided that the following conditions
REM are met:
REM
REM   * Redistributions of source code must retain the above copyright
REM     notice, this list of conditions and the following disclaimer.
REM
REM   * Redistributions in binary form must reproduce the above copyright
REM     notice, this list of conditions and the following disclaimer in
REM     the documentation and/or other materials provided with the
REM     distribution.
REM
REM   * Neither the name of Sebastian Bergmann nor the names of his
REM     contributors may be used to endorse or promote products derived
REM     from this software without specific prior written permission.
REM
REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
REM "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
REM LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
REM FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
REM COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
REM LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
REM CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
REM LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
REM ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
REM POSSIBILITY OF SUCH DAMAGE.
REM

if "%PHPBIN%" == "" set PHPBIN=.\php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "D:\xampp\php\phpunit" %*









*********************************************************End of original phpunit.bat file content************************************************





***********************************start of phpunit.bat file content after modification***************************************************



set PHPBIN=.\php.exe
"%PHPBIN%" "D:\xampp\php\phpunit" %*



***********************************End of phpunit.bat file content after modification***************************************************
Reply all
Reply to author
Forward
0 new messages