I'm working on a project that has me responsible for testing out some software that scrapes a web-page representing an input form, and generates a mobile friendly version of that page. This is particularly useful for form data, since not all websites have mobile-enabled browsers, and the aim of this project is to ultimately take these mobile-unfriendly pages, do some parsing on them, and then create a mobile-friendly version of said web-pages.

The code responsible for generating these mobile-friendly documents is more or less in javascript, which is the most untested portion of our code base. I want to find a way to test this code, and an idea came up amongst the team to see if there is some way to "record" a user's interaction with a web-site to disk such that locally, on the file system, there will be a series of N web-pages, each linking to one another on the file system. This way, we can generate test data rather easily for our project. There are several types of forms that we have to handle, such as forms that span across different web-pages, forms that have some javascript to hide aways certain fields, etc...

I'm not at all a web-developer; I'm more of a backend engineer. I think the greater goal we have is to find a way to test javascript that depends on the existence of specific types of forms; this latest requirement I have sort of grew out of that. Getting to the point, I have a couple of questions:

1) Is the creation and maintenance of this tool even a good idea? It would help create test data trivially assuming this was a browser plugin, but something about it seems kinda off to me.

2) What is the best way to do what I need to do, which is to find a way to test out some parser-javascript?

  • 2
    Your javascript needs to be able get the full page source before it starts processing it, right? From that point, it should be straightforward to persist the page source and reload it later for testing purposes, right? Or am I missing something? (By the way, tool recommendations are strictly off-topic for this site, better remove that part from your question, or do not be astonished when the community closes it soon.)
    – Doc Brown
    Sep 8, 2015 at 5:56
  • Thanks for the reply. Yes, it would be pretty trivial to just save these web-pages, and I guess the idea behind a plugin would be to make the whole process of just saving data easier on the user's end.
    – Waffles
    Sep 8, 2015 at 7:02
  • Maybe you can utilize Selenium for your case? (Disclaimer: I never used this by myself, but it seems to be very popular.)
    – Doc Brown
    Sep 8, 2015 at 14:44
  • The problem with that is whatever forms we're testing online can expire due to something out of our control, and then we're out of a test case. I guess we can always just download the html from each page, manually link them together in the source code, and use that as a test case?
    – Waffles
    Sep 8, 2015 at 17:35

2 Answers 2



1. is this a good idea?

I didn't know all details of your project, but sometimes there is no other way to provide testing, excepting writing user behavior scripts. It is hard enough to maintain such tests (because they depends on the UI, on names of css-classes, on ids of elements..), but on other hand they could give you confidence, that UI works as expected.

So, probably, yes — it is not a bad idea.

2. Best way to do ...

There are several tools, that could help you with this task

A) Selenium

You could try to use Selenium tests, they allow to automate user actions in the browser. So you could record simple scenario of user's actions, and later run it as a test so many times as you need.

Selenium is a Firefox extension, check it out: http://www.seleniumhq.org/

B) Headless browsers

There are a lot of headless browsers — almost the same browser as you use daily, but without UI. They could load webpage and interact with it through scripting interface (depends on implementation)

Take a look at CasperJS — it is a scripting wrapper around famous PhantomJS (and SlimmerJS)


Try creating an HTML file, and adding your javascript between the "script" tags. See Below:

            <TITLE>My Website</TITLE>
               <H5><I>My Junk</I></H5>
               <img src="1430639373_website.png"/>
               <p>I'm a programmer that programs in C, Python, and a little HTML, and I am learning Java programming.</p>
               <p>I'm a musician</p>
               <p>I'm a <i>Christian</i> first and foremost!</p>
               <p><a href="https://www.google.com/">My Email Address Provider</a></p>
               <P>I'm an American<P>

               document.write("Welcome new user!\n");
               var name=prompt("What is your name?"); 
               document.write("\nWelcome ",name);

  • 2
    Programmers is about conceptual questions and answers are expected to explain things. Throwing code dumps instead of explanation is like copying code from IDE to whiteboard: it may look familiar and even sometimes be understandable, but it feels weird... just weird. Whiteboard doesn't have compiler
    – gnat
    Sep 13, 2015 at 13:42

Your Answer

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

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