I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...
At the time of writing, PHPUnit does not support Selenium 2.
ReplyDeletephp-webdriver from facebook allows the complete WebDriver API to be called from PHP in an elegant way. To quote:
Most clients require you to first read the protocol to see what's
possible, then study the client itself to see how to call it. This
hopes to eliminate the latter step.
It is used by starting up the Selenium 2 server, which provides the interface at localhost:4444/wd/hub.
/usr/bin/java -jar /path/to/selenium-server-standalone-2.7.0.jar
then running the PHP test code, which calls that interface. For example:
<?php
require '/path/to/php-webdriver/__init__.php';
$webdriver = new WebDriver();
$session = $webdriver->session('opera', array());
$session->open("http://mysite.com");
$button = $session->element('id', 'my_button_id');
$button->click();
$session->close();
The WebDriver API is mapped to PHP methods, compare calling click on element in the example with the element/click API call in the documentation.
The test code can then be wrapped in regular phpUnit tests.
This is not native phpUnit support, but it's a quite robust approach.
PHPUnit Selenium integration code lives as a separate project in github, as far as I can see it does not support Selenium 2, so the answer to your question would be - No, you can not use Selenium 2 with PHPUnit.
ReplyDeleteBut you can clone the source tree and make it work with Selenium 2.
phpunit webdriver bindings are hosted on google code. There is something we need to understand beyond this.
ReplyDeletePHPUnit needs to be installed. (Either through PEAR package or download and install manually)
PHP IDE such as Eclipse PDT has to be downloaded and installed.
Selenium-Stand-Alone server has to be running while executing the WebDriver Selenium test