Hi, I’ve tried reading the Selenium RC doc and they’re still waiting for an example of using Selenium RC with PHP.
So here I am. I’m reading Agile Web Application Development with Yii 1.1 and PHP5 and I’m on the Selenium part page 46.
The problem I have is that I have a Virtual Private Server and I’m working on my laptop.
This is what I’ve done step by step on the VPS:
java -jar selenium-server.jar -port 4650
- Edit
protected/tests/WebTestCase.php
and added:
define('TEST_BASE_URL','http://test1.mypersonaldomain.com/demo/index-test.php/');
-
protected/test/phpunit.xml
deleted:
<browser name="internet Exploere" browser="*iexplore" />
- Added
date_default_timezone_set('America/Los_Angeles');
to
index-tests.php
because of php5.3
- Follow the book:
$cd protected/tests/
$phpunit functional/SiteTest.php
And this is the output I got after running
phpunit functional/SiteTest.php
:
PHPUnit 3.4.15 by Sebastian Bergmann.
EEE
Time: 0 seconds, Memory: 7.00Mb
There were 3 errors:
1) SiteTest::testIndex
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
2) SiteTest::testContact
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
3) SiteTest::testLoginLogout
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
FAILURES!
Tests: 3, Assertions: 0, Errors: 3.
The output for running selenium (
java -jar selenium-server.jar -port 4650
):
10:04:38.506 INFO - Java: Free Software Foundation, Inc. 4.3.2
10:04:38.507 INFO - OS: Linux 2.6.32.16-linode28 i386
10:04:38.512 INFO - v2.0 [a2], with Core v2.0 [a2]
10:04:38.649 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4650/wd/hub
10:04:38.650 INFO - Version Jetty/5.1.x
10:04:38.651 INFO - Started HttpContext[/,/]
10:04:38.653 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@59f00
10:04:38.654 INFO - Started HttpContext[/wd,/wd]
10:04:38.654 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
10:04:38.654 INFO - Started HttpContext[/selenium-server,/selenium-server]
10:04:38.656 INFO - Started SocketListener on 0.0.0.0:4650
10:04:38.656 INFO - Started org.openqa.jetty.jetty.Server@a36f00
What I think may have gone wrong:
-
I didn’t define the custom port in the test case, which lead to the question how do I do that? (Selerium RC doesn’t have a php example).
-
The port maybe in used. I’ve already did a netstat -a and I don’t think it’s in use.
-
Base on starting the Selerium RC and it’s output, the program thinks that I will be running it using 127.0.0.1 url. Maybe I should change the test_base_url to 127.0.0.1?
Anyway, this post sorta helped me sort out my ideas of what the hell is going on. I’m going to go test 2-3. I have no idea how to do 1.
If anyone have any idea, please point me toward the right direction.
Thank you in advance for your time.
The test case where it failed
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
is:
public function __call($name,$params)
{
if(is_array($this->fixtures) && isset($params[0]) && ($record=$this->getFixtureManager()->getRecord($name,$params[0]))!==false)
return $record;
else
return parent::__call($name,$params);
}
The Line 61 is:
return parent::__call($name,$params);
Progress:
I’ve added 4444 tcp port in my iptables now and I believe it can connect now. The problem now is:
PHPUnit 3.4.15 by Sebastian Bergmann.
EEE
Time: 1 second, Memory: 7.00Mb
There were 3 errors:
1) SiteTest::testIndex
PHPUnit_Framework_Exception: Response from Selenium RC server for getNewBrowserSession(*firefox, http://test2.anthonydoan.com:4650/demo/index-test.php).
Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin.
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
2) SiteTest::testContact
PHPUnit_Framework_Exception: Response from Selenium RC server for getNewBrowserSession(*firefox, http://test2.anthonydoan.com:4650/demo/index-test.php).
Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin.
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
3) SiteTest::testLoginLogout
PHPUnit_Framework_Exception: Response from Selenium RC server for getNewBrowserSession(*firefox, http://test2.anthonydoan.com:4650/demo/index-test.php).
Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin.
/var/www/yii/yii-1.1.3.r2247/framework/test/CWebTestCase.php:61
FAILURES!
Tests: 3, Assertions: 0, Errors: 3.
Now the question is this is a VPS server. I can’t run firefox on it. How do use firefox on my laptop instead.
What I think the solution is:
Selenium IDE?
Thank you again in advance.