I do most of my selenium (actually locator’s) debugging in chrome console, $() for css selectors and and $x() for xpath selectors but when it actually comes to debugging selenium/webdriver api calls I prefer interactive shell of programming language (python, ruby and php and pretty decent built in shells)
Bellow is how you can configure php shell to play around with selenium
Installation
- get composer Composer (If you don’t already use Composer)
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
- get psysh A runtime developer console, interactive debugger and REPL for PHP
wget psysh.org/psysh
chmod +x psysh
./psysh
Then install the library:
php composer.phar require facebook/webdriver
All you need as the server for this client is the selenium-server-standalone-#.jar
file provided here: http://selenium-release.storage.googleapis.com/index.html
Download and run that file, replacing # with the current server version.
java -jar selenium-server-standalone-#.jar
// author : Ahmed Mubbashir Khan
require_once 'vendor/autoload.php'; //composer generated autoload file
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;
$host = 'http://192.168.99.100:4444/wd/hub';
$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());
/*
Or if you wan't to modify $capabilities
use Facebook\WebDriver\Remote\WebDriverCapabilityType;
$capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox');
$driver = RemoteWebDriver::create($host, $capabilities);
*/
//e.g. Mouse over on an element
$element = $driver->findElement(WebDriverBy::id('some_id'));
$driver->getMouse()->mouseMove( $element->getCoordinates() );
Reference:
- [1]: http://selenium-release.storage.googleapis.com/index.html
- [2]: https://github.com/facebook/php-webdriver
- [3]: https://getcomposer.org/
- [4]: http://psysh.org/
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
wget psysh.org/psysh
chmod +x psysh
./psysh
php composer.phar require facebook/webdriver
selenium-server-standalone-#.jar
file provided here: http://selenium-release.storage.googleapis.com/index.htmljava -jar selenium-server-standalone-#.jar
// author : Ahmed Mubbashir Khan
require_once 'vendor/autoload.php'; //composer generated autoload file
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;
$host = 'http://192.168.99.100:4444/wd/hub';
$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());
/*
Or if you wan't to modify $capabilities
use Facebook\WebDriver\Remote\WebDriverCapabilityType;
$capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox');
$driver = RemoteWebDriver::create($host, $capabilities);
*/
//e.g. Mouse over on an element
$element = $driver->findElement(WebDriverBy::id('some_id'));
$driver->getMouse()->mouseMove( $element->getCoordinates() );
Reference:- [1]: http://selenium-release.storage.googleapis.com/index.html
- [2]: https://github.com/facebook/php-webdriver
- [3]: https://getcomposer.org/
- [4]: http://psysh.org/