I'm trying to find specific information on how to setup Selenium with PHP bindings in a 'client-server' type of setup. I'm not even sure if what I want is possible, but I will try to do my best to describe the objective of what I am trying to achieve.
I do QA on a Web development project, where we are working with distributed team members. We need automated front end testing, and have decided that (due to a number of factors) Selenium makes the best candidate for the job. Our team is specialized in PHP, so it makes sense to use Selenium with PHP bindings.
My biggest challenge is:
1) How do I install those PHP bindings?
2) How do I create and execute a Selenium script in PHP? This one might seem obvious, but I need to know if I need to create some sort of 'project' in PHP, or whether this requires different steps. Manuals are very clear and detailed when it concerns the default JAVA bindings, but hopelessly lacking on the PHP bindings.
3) How do I do all this, while wanting to invoke a test from a client, but having it executed by a 'server/VM'? (Keeping in mind that if the possibility were there, I would also like to be able to create tests on the server, that can execute/invoke testing activities on the desktop of the client.)
4) How do I setup a server that meets all requirements to run Selenium Server with PHP bindings?
The objective is to be able to initially create a VM (probably a Vagrant box) that would contain Selenium Server (and if needed other components) with the actual test scripts, which can be shared among team members. This VM should both be able to execute headless tests, but ideally should also be able to drive tests on the host (if at all possible).
Technically it should support the scenario where QA finds an issue in the product, and should be able to just specify the required script to reproduce it. The developer that has the task to fix the issue should only have to run the script on his machine to actually reproduce the found error.
Eventually we would want to migrate the VM to an actual server, hence the reason we want to set it up like this from the start. This will keep things more simple once we are ready to move to a physical server.
I've been looking all over the internet for detailed documentation, but in just about any documentation many assumptions are made about already configured and set up environments. I really need a step by step explanation of how to set things up.
PHPUnit seems a bit of a weird choice to pair with Selenium, since they both cover completely different areas of testing. I have seen (again incomplete) instructions on the PHPUnit site, but that seems very clunky and our development team is not very keen on this setup. We have people suggesting Jenkins, but I personally do not see how Jenkins would eliminate the normal setup of Selenium, which one has to go through from the start anyway.
I already have Selenium Server running as a service in a VM, I just need to know what else I need, and how I need to set it up, how to configure it. how to make things communicate, etc.
Any help/ideas would be highly appreciated.
To get this running locally, follow the instructions here:
https://github.com/facebook/php-webdriver#getting-started
Here is a sample PHP webdriver script that you can use. It will open firefox, take you to google's page and submit a search query:
// you'll need to modify this path so it points to the composer autoloader
require_once __DIR__ . '/vendor/autoload.php';
/**
* since I'm running the selenium jar locally, this is all I need.
* I just run it in the background and my php scripts connect to it and
* the tests
*/
$host = 'http://localhost:4444/wd/hub';
$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());
$driver->get('http://google.com');
$element = $driver->findElement(WebDriverBy::name('q'));
$element->sendKeys('Cheese');
$element->submit();
Is this the sort of detail you're looking for?
If you a visual learner like me, this
Selenium WebDriver set up with PHP - Selenium PHP traininig
will help you do that. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With