It's not as easy as it looks!



  • Avatar
    Andy Kemp

    Hi Hazzi,

    Glad to hear you are trying out Twist.

    Your question is not stupid. As you suggested a context is usually the best place to keep code that navigates to the website you want to test. That way you can keep the code in one place for all you scenarios. Currently we don't support the ability to record a context, but this shouldn't stop you easily doing what you need to do, even if you don't know any Java yet.

    I am assuming you have already recorded at least one test step which includes the code to navigate to the website you are interested in. You will just need to create a context and then copy the code into your new context, as follows.

    • From the test step you recorded, navigate to the underlying Java code by pressing F3 when your cursor is on the test step.

    • Copy the line "browser.navigateTo("");" (if you don't see this line, try recording again).

    • Create a new context by clicking on the "+ Add" icon in the Context bar with the test scenario view

    • Type a name you would like to give your context, click on the triangle icon next to the name and select "Create Context". Click finish on the dialogue box that appears.

    • Navigate to the code that has been generated for the context by pressing F3

    • You should see some Java code that has been generated by Twist
      Find the section that reads;
          public void setUp() throws Exception {
              //This method is executed before the scenario execution starts.

    • Edit this code by pasting the line you copied earlier so that it looks like this
          public void setUp() throws Exception {
              //This method is executed before the scenario execution starts.

    • Once you have saved all your files, you should be able to use this context in any of you scenarios.

    If you create a new scenario, you can add this context before you record and Twist will navigate to you your website before recording starts.

    I hope this helps.



    Comment actions Permalink
  • Avatar

    Hi Andy,

    thanks for that, it worked like a charm.

    I expect I will have more questions before I get this all running smoothly, it's nice to know I can get a quick and readable response.



    Comment actions Permalink

Please sign in to leave a comment.