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?
Related
What I'm looking for is an easy way to get either individual core usage or total CPU usage for the system that the PHP Script is running on.
However I'm unable to do so. I've looked all over for all manner of solutions from using perf (with and without passthru) to using winmgmts through COM.
The issue is, some of these will work on Windows if you use Apache, but with IIS the security restrictions stop PHP from being able to use for example winmgmts through COM so I just get back a null object.
How can I solve this? - I've honestly tried every solution I can find on the internet and while there is lots of information about how to raise the permissions all the guides point to IIS 7 or earlier and are no longer applicable to IIS 8.5 with literally the suggested option changes being non-existent.
If anyone could help me with this I'd be really appreciative, a workaround like using a third party application that could provide this data would also be acceptable if I can query the data through PHP either from a file or network etc Even a asp.net script that I could query? (I don't know anything about asp.net but I could use it for this single thing if it'd work?)
Thank you.
I managed to solve this and I hope it helps someone else.
What you must do is convert the folder where your PHP (or asp) will execute to an Application. So the structure will look like this:
Website Name
-> Application Name
Then you want to select the parent folder, the Website Name folder and go to "Basic Settings" in the far right actions pane and select "Connect As..." and connect as an Administrator account.
Once you've done this the application will inherent the credentials you specified on the parent website folder and you'll now have full access to perf, wmi and so on.
If you only give the credentials directly to the application it doesn't work and it also doesn't work if you don't convert your folder where your scripts will execute to an application. This is where I was being tripped up and the documentation online is very sparse.
I'd like to thank the good people at the phpsysinfo github for their IIS documentation which pointed me on the right track on needing to convert a site to an application which was part of the puzzle I was missing.
I'm working in a web agency with a small team (5 developers, 2 designers). We primarily work with PHP/MySQL web applications including Magento, Experession Engine and CakePHP. We use a combination of Windows 7 PC'S (developers) and Mac's on OSX (designers).
I've been looking into using github for our projects with 3 main goals:
To see who has edited files and allowing people to comment on files.
To avoid overwriting each others work as it's sometimes the case multiple people can try and work on the same file at the same time.
Allowing rollbacks to previous versions of a file.
This is our current workflow and I don't understand how github fits in with this at all. I realise that our workflow will need changing but I haven't been able to find a process which in any way seems to fit in with this:
All our work is done on a remote web server which is specifically for development (nothing "live" sits on here). The server is running Apache, PHP, MySQL, etc. Nobody has a local development environment set up on their machine and we don't want that if possible.
We all have FTP access to the development server mentioned above. We generally edit files directly on this dev server as it gives a very quick way to test things out (literally edit a file, upload it and run it in the browser). There are problems with conflicts, e.g. multiple people trying to edit the same file, which is why I'm looking into using git.
When everything has been approved on the development server it is made live by copying it to a different server. The live server can be anywhere - we use some servers we manage ourselves, sometimes we use third party hosting companies - it varies.
I've been looking into this for the last couple of days and all the approaches I'm finding seem impossible for us to use. Does anyone have any insight into the best way to achieve this? Or am I looking into something which isn't even applicable for the issues I'm trying to resolve?
I would appreciate any useful advice people can offer.
Thanks.
We have a very similar set up in the company I work. We actually have a different sandboxes on the dev server. In other words, we clone the repo into different sandboxes. Each developer/designer gets a sandbox. For example if there are 3 developers, there will be 3 sandbox directories + 1 staging directory
So, developer john gets /home/john/example.com and it can be viewed at john.example.hot (setting up vhosts)
mike gets /home/mike/example.com viewed at mike.example.com
tracy gets /home/tracy/example.com viewed at tracy.example.com
And there will be one additional staging directory. /home/staging/example.com staging.example.com
Staging merges all the changes together so it can be tested. All of these directories are accessible only with internal IPS.
We deploy these changes to production using RSYNC. More information here about RSYNC: http://www.cyberciti.biz/tips/linux-use-rsync-transfer-mirror-files-directories.html
You could create a git repository at your testing machine and have every one of your team use git to push their changes to that repository. This way they will get notified, when their changes will conflict with those of other people.
A typical workflow could look like this:
Developer1 changes something at his machine.
Designer1 changes some files on his machine
Designer1 commits those changes to his local git repository
Developer1 commits those changes to his local git repository
Developer1 pushes his changes to the development machine.
Designer1 pushes his changes to the development machine
in case of conflicts with the changes of Developer1 he will now be prompted what those conflicts are and will have to resolve them.
Then the resolved changes will be pushed to the development machine.
This should fix your problem 1.) and 3.) and will make 2.) an explicit action, which means that your developers and designers will see what they are overriding. If changes happen at different parts of a file at the same time, than git may be able to keep both changes without needing further interaction.
But beware, that this still has the problem, that no one will get to test his own changes without interference of other people as those may change things at any time while someone is trying to test something. With only 1 development machine you can not prevent this from happening with git alone. As your team is rather small and your current approach doesn't fix this either it might be of little significance to you.
I was wondering how to start coding a script using php, and that script will be used on many websites.
so should I start first by creating the database ? and then start creating php files that will process data from the database ?
and should I start thinking of an install wizard for this script at first, or later when I finish the project I'll create one ?
I'm really confused on how to start a project, can you please give me some advice ?
and thanks everyone :D
should I start first by creating the database?
If you are going to use a database in your PHP script, then yes, you should install a database first. MySQL is a good start.
and then start creating php files that will process data from the database?
I would start on one server first, and create one PHP file called index.php that will do a database query. Then work your way to multiple PHP files from there.
and should I start thinking of an install wizard for this script at first, or later when I finish the project I'll create one.
Installing PHP files is 90% of the times as simple as just copying them onto your new server. I wouldn't worry about an install wizard just yet.
Another general tip because you are a beginner: install WAMPServer, it is a webserver/PHP server/MySQL Server in one that runs on your local computer. This is great for developing because you can just put your PHP files in C:\WAMP, edit them and directly see the result in your browser through http://localhost/. Then when you are happy you can upload to the server, or multiple servers. (Just by copying).
Most php software does not have, or need for that matter, what you would call an install wizzard.
I would suggest you to develop whichever way feels most natural to you.
Some people find it easier to start with the database design, while others prefer to write some code first and then expand the db schema further. There really is no right way to do it.
Starting a PHP project can be as easy as creating a text file and pumping out lines of code, however if you plan on creating a sizeable project, I would suggest a fully featured IDE.
Decide what dependencies your script has.
Decide which minimum version of PHP the script will be compatible with.
Work out a script which queries the users setup to detect whether these conditions are met or not. (eg does it rely on the mysql extension to be installed).
Detail how to meet each of the dependencies in case they are missing.
Explain which is the minimum version number supported, if your script detects it is below that version number.
Test it on your target Operating Systems.
Run a script which creates a database, test whether that was created. Provide detailed instructions on how to do this manually, and how to provide the correct privileges.
If necessary give them a config file which permits them to enter key information such as doc_root etc.
Conform to common wisdom such as short_tags = off else override these settings. Imagine the user is on shared hosting and is running on safe_mode = on.
Try and follow your own instructions and re-install it on your localhost, then on a live server - ideally on a variety of OSs too.
I've decided to code some applications in PHP that are supposed to run offline in the user's machine. However, I can't seem to find an user-friendly install wizard to create a local server in where the script will run. Any ideas?
PS: Here's an example of what I want: http://www.nolapro.com
You could go to the old school route and try using PHP-GTK.
Text Tutorial here: http://www.kksou.com/php-gtk2/References/Compiling-standalone-PHP-GTK2-applications-on-windows-using-PriadoBlender.php
or you could go the route that I believe has much more promise: Adobe AIR + PHP
It has the added bonus of running on any platform!
Video tutorials here: http://www.vtc.com/products/Adobe-AIR-PHP-Development-Tutorials.htm
There's also a new player in the game, Appcelerator. It lets you write your code in whatever language you want (PHP, Ruby, Python, etc) and compile it for the platform of choice (iPhone, Android, Windows, OSX). Parts of it are still beta, but it looks unbelievably slick & cool, and there are lots of tutorial videos. http://www.appcelerator.com
I hate to advocate this, because it just feels so wrong. You would probably be better off using a language inteded for use for stand-alone applications, if you're going to be doing this often or in a production setting.
With that said, a colleague of mine used to use the Bambalam PHP to EXE Compiler for this. He actually had a profitable product built around it.
Bambalam will generate an EXE that doesn't rely on any external DLLs, based on your PHP code.
http://www.bambalam.se/bamcompile/
If you have a webapp written, you maybe want to deploy on client, a possible way is use wapache, which is a standalone apache bundled with your application, and an integrated (IE) browser control inside.
http://wapache.sourceforge.net/
A new feature of PHP 5.4 & 6 can help you, the builtin web-server.
http://php.net/manual/en/features.commandline.webserver.php
With this feature you can host locally your php app without external webserver, and access on localhost.
If you really talking about a client application you are really wrong to do this.
If you want to wrap a server + browser to deploy your web based application so it runs local you might check out three options:
1) Deploy a simple webkit browser (you can get a QT Webkit Browser in 30 lines of code) and an apache server that is installed somewhere standalone (not via the apache control script as this uses port 80 and i probably conflicts with another installed webserver.
2) Look at the Firefox PRISMA solution. I have read about this only in a news article but it wrapps the firefox around one single start URL. You have to deploy a webserver in the same way as
3) Try to wrap it as a HTA application. Search the corresponding info on MSDN.
I would prefer (1) as you can add special application interacting code as needed.
At my company we have a group of 8 web developers for our business web site (entirely written in PHP, but that shouldn't matter). Everyone in the group is working on different projects at the same time and whenever they're done with their task, they immediately deploy it (cause business is moving fast these days).
Currently the development happens on one shared server with all developers working on the same code base (using RCS to "lock" files away from others). When deployment is due, the changed files are copied over to a "staging" server and then a sync script uploads the files to our main webserver from where it is distributed over to the other 9 servers.
Quite happily, the web dev team asked us for help in order to improve the process (after us complaining for a while) and now our idea for setting up their dev environment is as follows:
A dev server with virtual directories, so that everybody has their own codebase,
SVN (or any other VCS) to keep track of changes
a central server for testing holding the latest checked in code
The question is now: How do we manage to deploy the changed files on to the server without accidentaly uploading bugs from other projects? My first idea was to simply export the latest revision from the repository, but that would not give full control over the files.
How do you manage such a situation? What kind of deployment scripts do you have in action?
(As a special challenge: the website has organically grown over the last 10 years, so the projects are not split up in small chunks, but files for one specific feature are spread all over the directory tree.)
Cassy - you obviously have a long way to go before you'll get your source code management entirely in order, but it sounds like you are on your way!
Having individual sandboxes will definitely help on things. Next then make sure that the website is ALWAYS just a clean checkout of a particular revision, tag or branch from subversion.
We use git, but we have a similar setup. We tag a particular version with a version number (in git we also get to add a description to the tag; good for release notes!) and then we have a script that anyone with access to "do a release" can run that takes two parameters -- which system is going to be updated (the datacenter and if we're updating the test or the production server) and then the version number (the tag).
The script uses sudo to then run the release script in a shared account. It does a checkout of the relevant version, minimizes javascript and CSS1, pushes the code to the relevant servers for the environment and then restarts what needs to be restarted. The last line of the release script connects to one of the webservers and tails the error log.
On our websites we include an html comment at the bottom of each page with the current server name and the version -- makes it easy to see "What's running right now?"
1 and a bunch of other housekeeping tasks like that...
You should consider using branching and merging for individual projects (on the same codebase), if they make huge changes to the shared codebase.
we usually have a local dev enviroment for testing (meaning, webserver locally) for testing the uncommited code (you don't want to commit non functioning code at all), but that dev enviroment could even be on a separeate server using shared folders.
however, committed code, should be deployed to a staging server for testing before putting it in production.
You can probably use Capistrano even though is more for ruby there are some articles that describe how to use it for PHP
I think Phing can be use with CVS but not with SVN (at least that what I last read)
There are also some project around that mimic Capistrano but written in PHP.
Otherwise there is also a custom made solution :
tag files you want to deploy.
checkout files using the tag in a
specific directory
symlink the directory to the current
document root (easy to rollback to
the previous version)
Naturally check out SVN for the repository, Trac to track things, and Apache Ant to deploy.
The basic process is managing in Subversion, tracking the repositroy and developers in Trac and using Ant deployment scripts to push your site out with the settings needed. Ant allows you to easily deploy a project to a specific location. (Dev/test/prod) etc.
You need to look at:
Continuous Integration
Running unit tests on check-in of code to check it is bug free
Potentially rejecting code if it contains a bug
Having nightly builds
Releasing only the last build that was bug free
You may not get to a perfect solution, especially not at first, but the more you use your chosen solution, the more comfortable everyone will get and be able to make suggestions on improving it.
We check for the stability with ant, every night. And use ant script to deploy. It is very easy to configure and use.
I gave a similar answer yesterday to another question. Basically you can work in branches and integrate before going live.
The biggest thing you will have to get your head round is that you are dealing with changes to files, rather than individual files. Once you have branches there isn't really a current version there are just versions with different changes in.