Configuration File for Driving Selenium Configuration File for Driving Selenium php php

Configuration File for Driving Selenium


A long time back at one of my project I had a similar requirement. I tried to create a Robot (or someone may call Web Crawler). As I started navigating through the pages I started maintaining the navigation paths in spreadsheet, so I don't have to click on the paths manually. Once I have the paths, next time whenever a Path changes I will be notified and if it is a valid change then make that change in s/s or raise it as a bug.


As you said you have all relevant details in the database then you just can simply read it and in a foreach loop pass to selenium driver.

or if you don't want to have a reference to the database in your test, just dump data to PHP array and add to your test class.

You just need to write a logic to transform your sql data into test. Don't need to write every test manually.

I don't know which testing framework you are using, but you can execute many tests from a single test for example in PHPUnit that would be something like:

class My_PathsTest extends PHPUnit_Framework_TestCase{    public function setUp() {      // setup $this->tests here     }    public function testAll() {        // $this->tests would contain info about paths taken from database.        $failures = array();        foreach($this->tests as $paths_set) {            try {                /**                 * $driver->get($paths_set['start_point']);                 * foreach ($paths_set['paths'] as $path ) {                 *  $driver->findElement(WebDriverBy::xpath($path));                 * }                 *                  * Important!!!                 * If you didn't find something you expected                  * just throw the PHPUnit_Framework_ExpectationFailedException exception                 * throw new PHPUnit_Framework_ExpectationFailedException('Element missing add some info here about which is missing etc..');                 */            }            catch(PHPUnit_Framework_ExpectationFailedException $e) {                $failures[] = $e->getMessage();            }        }        if (!empty($failures)) {            throw new PHPUnit_Framework_ExpectationFailedException(count($failures) . " assertions failed:\n\t" . implode("\n\t", $failures));        }    }}


best is to get data from db with odbc as a list (array) xpath locators and then loop over it. If you don't have a direct access to the db, export the query results as a .csv file (MS db has an option save as, not sure about the others) and then read the file and loop over the array