Quick Start/Tutorial 3 Video

Here is a (5 minute) video that goes through all the steps listed bellow:

Identify Another New Test Case

Lets generate another new test case where we will have to put a scripted Action to achieve our testing objective.

  1. Open Browser and navigate to www.amazon.com
  2. Search for ‘Star Wars blu ray’
  3. (new action) Check the ’1970 – 1979’ check box for ‘Movie & TV Show Release Decade’
  4. Select first item that appeared by index
  5. Add the item to cart
  6. Verify item was added to cart

Add New Action

In order to work with ‘check box’ controls for ‘Movie & TV Show Release Decade’ we’ll need to create a new action. The actual controls in amazon are not check boxes (they are links that render differently based on click) and because of that this is a good opportunity to show how to create a fully scripted action.

First, lets create a script for our new action:

  1. Click on Scripts tab
  2. Expand ‘src’ folder in left pane
  3. Right click on ‘actions’ folder and select New -> Java Action
  4. Type in ‘CheckMovieTVReleaseDecade.java’ and click OK
  5. Type in the code to handle the check box part of amazon page (copy/paste the code example bellow to replace the template code that appears):
    package actions;
    import actions.selenium.Browser;
    import org.openqa.selenium.*;
    import org.openqa.selenium.support.ui.Select;
    import java.util.*;
    public class CheckMovieTVReleaseDecade {
         public void run(HashMap<String, Object> params) {
            WebElement element = Browser.Driver.findElement(By.xpath("//*[@id='leftNavContainer']//SPAN[text()=\""+params.get("Date range value")+"\"]/../../INPUT"));
            if((Boolean)params.get("Check") && (element.getAttribute("value").contains("false"))){
                element.click();
            }
            else if (!(Boolean)params.get("Check")&& element.getAttribute("value").contains("true")){
                element.click();
            }
            try{Thread.sleep(4000);}catch(InterruptedException e){}
         }
    }
  6. Click on Build Scripts button (grey button with downward arrow) to make sure it compiles correctly and there are no errors
  7. Click on Save and then click on Git Push (computer with green arrow button) and then OK to push the code we just created to main branch. We will discuss more about Git in Quick Start 4.

Now lets create an Action definition to be used by Test Case(s):

  1. Click on Actions tab
  2. Click on New Action button
  3. Type in ‘Check/Uncheck the Movie & TV Show Release Decade checkbox’ for name field
  4. Keep ‘Script’ selected since this is going to be a scripted action
  5. For ‘Tags’ field, type in ‘amazon’ and press enter
  6. Add 2 parameters with the name exactly as they appear in the code we developed:
    - Name first one ‘Check’ and specify Parameter Type for it as ‘Boolean’
    - Name second one ‘Date range value’
  7. For ‘Select Script’ field point to our class method we just created by typing in: actions.CheckMovieTVReleaseDecade.run
    - Alternatively you could have used script picker (a looking glass icon button to the right of Select Script field) to select the method.
  8. Now that we are happy with our action, for ‘Status’ drop down (bellow Description text field) select value ‘Automated’
  9. Click on Save button and you should see your new action looking like this:

Clone Test Case

Since this test case looks very similar to the ‘Add Star Trek to Cart’ lets clone it and add the new action step we just created.

  1. Click on Test Cases tab
  2. Double click on ‘Add Star Trek to Cart’ test case to open it
  3. Click on Clone button (to the right of Delete one)
  4. Type in name ‘Add Star Wars to Cart’ and click OK
  5. In a left pane click on Actions or Actions Tree and locate our new action called ‘Check/Uncheck the Movie & TV Show Release Decade checkbox’
  6. Drag and drop our new action between Search Amazon and Select Item actions
  7. Type in the following values for the new action:
    - Check = TRUE
    - Date range value = 1970 – 1979
  8. For ‘Search Amazon’ action modify it to the following values:
    - search for = Star Wars Blu Ray
  9. Since we are expecting to have a lot of test cases to be executed, lets make this more compatible with that idea by specifying ‘After State’ (expand top portion of ‘Test Case Details’ by clicking on little triangle button first) by typing in ‘Close Current Window’ in that field and selecting it when it appears and press Enter to add it to After State action collection (or just drag and drop it there). What will happen is whatever action specified in that field for that test case will get executed after test case has finished running (and in our case it will close current browser window so if we execute 100 test cases we wouldn’t have 100 browsers opened at the end)
  10. Click on Save and you should see your test case looking like this:

New Execution

Lets create a new Execution and use the existing Test Set where you will specify a new test case that was just created.

  1. Click on Execution tab
  2. In left pane click on ‘Test Sets’
  3. Click on Edit button for ‘Amazon Shopping’ test set (or double click on it)
  4. Expand ‘amazon’ tag and check the checkbox for ‘Add Star Wars to Cart’ (or uncheck and then check ‘amazon’ check box which will now check all test cases which belong to that tag)
  5. Click on Save and click on Yes in message box
  6. In left pane click on ‘Executions’
  7. Under ‘All Executions’ click on ‘New Execution’ button
  8. Type in Name ‘New Amazon Execution’ and for Test Set set it to ‘Amazon Shopping’
  9. Expand ‘Settings’ by clicking on little triangle button next to name
  10. Check the checkbox for ‘No After State’ so that browser wont close for this run and we can see it open after test is done for now (for official test case runs you want this unchecked)
  11. Click on Save button
  12. Expand ‘Set Variables’ by clicking on little triangle button next to name
  13. For ‘Browser’ under ‘Set Variables’ select the browser you want to run the test cases against by clicking on the Value field for it (which should have ‘Firefox’ by default) and click on drop down arrow to specify other browser (Internet Explorer or Chrome)
  14. Under ‘Select Machines’ check the check box for ’127.0.0.1’ (agent was installed with RedwoodHQ server)
  15. Under ‘Test Cases’ check the check box for our new test case ‘Add Star Wars to Cart’
  16. Click on ‘Run Selected Execution’ green arrow button on top
  17. Test case will now run and then when it’s done the test case will have status of ‘Finished’ with result ‘Passed’

Feedback

Thanks for your feedback.

Post your comment on this topic.

Please do not use this for support questions.
For customer support, please contact us here.

Post Comment

PrimaTest wrote: Mar 26, 2017

You cannot clone an execution, but there are only 2 fields there that you set: Name and Test Set.
You can also specify default execution variable values (on execution creation) by specifying them in Variables page.


Vipul wrote: Mar 23, 2017

Is there any way to clone the test execution?