Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Using previous written code?

  • 18-01-2013 06:35PM
    #1
    Banned (with Prison Access) Posts: 196 ✭✭


    Howdy, learning the basics of Java

    Can anybody tell me what i should read up on to get a quick idea of using code for automation purposes, for instance:

    I write code/test script to login to a website => this logs me in and gets me to say a home page => on the home page i want to add criteria into fields, all is well.

    However, this would be a different test script, so to proceed on i want to reuse the last script code for logging in. Is this extends class?

    Please point me in the direction of reading material.

    Apologies if this is a stupid question!


Comments

  • Registered Users, Registered Users 2 Posts: 52 ✭✭iFergal


    Try creating an object of your first class in your second class.

    firstClassName objectName = new firstClassName();

    Replace firstClassName with the name of the class with the login code and add arguments to the parameters if your constructor has any. And to use the methods from that class just type as an example - firstClassName.methodName.


  • Registered Users, Registered Users 2 Posts: 27,517 ✭✭✭✭GreeBo


    Have you looked into using something like Cucumber/web driver for automated testing?

    Excellent for checking the behaviour of your site, rather than just running code.

    You can build up scripts to do anything, and then reuse them as you want.
    e.g
    write some code that checks that login works successfully
    write more code to check the home page works, this would resue the login code.

    etc, etc


Advertisement