How to setup Selenium webdriver and execute automation script
May 28th, 2012
- Selenium 2.0 includes selenium web driver compatible version.
- Download Selenium 2.0 from http://seleniumhq.org/download/
- Install Java JRE, JDK is not required until you want to create Java programs
- Check java version- java –version on command prompt, to be sure you have java installed
- Start selenium through command prompt: java -jar selenium-server-standalone-<version-number>.jar
- You can also Stop Selenium through browser: http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
- Write code in PHP i.e. download library (php-webdriver-bindings-0.9.0.zip) from http://code.google.com/p/php-webdriver-bindings/ to execute selenium scripts
- Save the following code as “myseleniumscript.php” file.
$webdriver = new WebDriver("localhost", "4444");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
$element->sendKeys(array("selenium google code" ) );
- Make sure you have php and supporting web server like Apache already installed. Download “wamp” to install PHP, Apache
- Run the file as localhost/myfolder/myseleniumscript.php in browser, this will open up a new firefox window and you can also check the command prompt for execution log
You can leave a response
, or trackback
from your own site.