4

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.

asked Jan 17, 2011 at 22:58

3 Answers 3

1

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.

answered Jan 18, 2011 at 0:57
1
  • 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. Commented Jan 18, 2011 at 12:12
3

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

answered Jan 17, 2011 at 23:06
3
  • +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. Commented Jan 17, 2011 at 23:10
  • Please avoid the overuse of formatting: your answer is fine without it. Commented Jan 18, 2011 at 0:48
  • @Mark: I simplified it, but an overuse of formatting is better then none. Commented Jan 18, 2011 at 1:02
1

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?

answered Jan 17, 2011 at 23:06
1
  • Nope, it isn't a testing script, its a live script used to log in to a service, update some information and log out. Commented Jan 17, 2011 at 23:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.