Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've recently begun working on a PHP application, replacing another developer. I believed the application was using an API to communicate with a remote service but when I looked through the code I found that it was using a set of functions to actually log in, fill out forms and submit them as a user might do in a browser.

My intention is to replace this code, to use the services API instead. I've considered leaving the code as is and not replace it. It makes me wonder though is this a common practice in the software industry? To have a programme simulate a users actions in a browser to perform a set of actions? It feels to me that this is clever but poor programming, Have any other developers seen this?

Edit: Sorry, should have added this in the first place, the code I describe isn't part of a testing suite, its live code.

share|improve this question

3 Answers 3

up vote 0 down vote accepted

Although many may view this as generally a bad idea to implement such practices, there may have been a legitimate reason for doing this sort of thing.

As developers, many of us do like to perfect our code to minimize our technical debt; however, at the end of the day the one thing we must remember is that we are hired to meet a business goal. Sometimes meeting those goals involve some creativity, thinking outside the box, and doing things that would be considered out of the ordinary and contrary to what the rules/guidelines say to do.

If you wanted to fix the problem, I don't see why you couldn't, but I wouldn't knock the original developer because this tactic -- back when it was implemented -- could have meant the difference between saving a client and losing a client.

share|improve this answer
    
Hi jmort253, Thanks for your comment. You're probably right in this case as simulating a user seems to give the application more abilities as the API currently supports. –  Gortron Jan 18 '11 at 12:12

No

That is not standard practice. If it's using an API then any automated tasks should use that same API without resorting to browser manipulation to do so.


Automated UI manipulation can be done with many different tools.

I prefer to use Selenium.

Selenium can be used for more then testing, even though that is what it was designed for. If you wanted to go that route

share|improve this answer
    
+1 You can use the Selenium IDE plugin to grab a quick script and run, or you can write code in a handful of languages like C# or Java to integrate them into code and even NUnit tests that can be run against automated builds. Pretty nice. –  Ryan Hayes Jan 17 '11 at 23:10
    
Please avoid the overuse of formatting: your answer is fine without it. –  user8 Jan 18 '11 at 0:48
    
@Mark: I simplified it, but an overuse of formatting is better then none. –  Josh K Jan 18 '11 at 1:02

Wait - are you talking about some sort of test suite? If so, this is fairly common, although in web-app land it's probably more common to use a product like Selenium to simulate the user's interaction with your page instead of mocking service calls independent of the interface.

If this isn't the case, can you clear up what's actually going on?

share|improve this answer
    
Nope, it isn't a testing script, its a live script used to log in to a service, update some information and log out. –  Gortron Jan 17 '11 at 23:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.