RedwoodHQ is a Server
Since RedwoodHQ is a multi-user test automation framework server it is assumed that multiple users will be able to login and work in it. As mentioned before, you should have only 1 RedwoodHQ server up and running while everyone connects to that IP address through their browsers (so no need to install anything for other users). Don’t be afraid for your data if this is just your test environment and you are planning to move to a more permanent one later on, just follow these Migration steps when you are ready to do so (if you are planning on keeping anything you create).
Add New User
In order for another person to use RedwoodHQ let’s create a new user first:
- Click on Settings tab
- Click on Add User button
- Type in the following values:
- User ID = test
- First/Last Name = Test User
- Email = test@test.com
- Password = test
- Repeat Password = test - Click on Submit button and you will see user ‘test’ appearing with the ‘Status’ red next to it (because that user is not logged in) like this:
Login as a New User
Now that new user is created, try to login with on either same machine as a current one or from a different machine altogether to simulate other user accessing RedwoodHQ.
If you just want to login on the same machine as where you are currently logged in as user admin then do this:
- In top right hand corner click on word ‘admin’ and click on Logout
- Click on Yes on prompt
- In the Login page type in:
- Username = test
- Password = test - Click on Login button and you will get logged in as a test user
If you want to login from a different machine then do this:
- Open browser and type in the ip address of RedwoodHQ server machine + port number (typically 3000) that was specified during install (eg: http://192.168.44.554:3000). If you don’t know the IP address then just follow these steps on RedwoodHQ server machine
- In the Login page type in:
- Username = test
- Password = test - Click on Login button and you will get logged in as a test user
Code and Git Repository
Each user has their own code they work with that is regulated by internal Git repository, so if my user test does any type of modification to the code and doesn’t ‘push it’ then other users will not see his changes. This is done so when a user works on their code, they are not concerned that they will interfere with other users code and executions and only push when they feel confident to do so. User also has an option when to Pull the code from main branch that was pushed by other users. Here is the scenario of how this works:
- As a logged in user ‘test’, click on Scripts tab
- Expand ‘src’ and ‘actions’ folders in left pane and double click on ‘CheckMovieTVReleaseDecade.java’ file
- Modify the code by adding a print statement and making xpath of element invalid and adding a new java import to handle println, so your code should look like this:
package actions; import static java.lang.System.out; 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) { out.println("This is a hello from user test!"); WebElement element = Browser.Driver.findElement(By.xpath("//invalidxpath//img[@alt=\""+params.get("Date range value")+"\"]")); if((Boolean)params.get("Check") && (element.getAttribute("src").contains("checkbox_unselected"))){ element.click(); } else if (!(Boolean)params.get("Check")&& element.getAttribute("src").contains("checkbox_selected")){ element.click(); } try{Thread.sleep(4000);}catch(InterruptedException e){} } }
- Click on Build Scripts button (which will automatically save the script) and DO NOT click on Git Push yet
- Go to Execution ‘New Amazon Execution’ and run the ‘Add Star Wars to Cart’ test case (if you are not sure how, follow these steps in Quick Start 3)
Execution Analysis
Because we have purposely modified the script to fail by specifying invalid xpath, we see that the test case has failed and now it’s a good opportunity to see how we can analyze the results of it.
- While still in ‘New Amazon Execution’ click on ‘Add Star Wars to Cart’ link under Test Cases section to open Test Details for it
- In this section we can see all the actions that have passed, failed or not ran and their appropriate values
- Since ‘Check/Uncheck the Movie & TV Show Release Decade checkbox’ action has failed, it has expanded and contains screen shot, error and a stack trace
- Bellow Results there is a Logs section that shows all the print statements that were made by your code, in our case you should see ‘This is a hello from user test!’ print statement
- Click on ‘View’ button to have new tab open to show you a screenshot at which point the action has failed
- Close the screenshot tab and click on stack trace link ‘actions.selenium.CheckMovieTVReleaseDecade.run(CheckMovieTVReleaseDecade.java:10)’ which now goes to exact line failure on Scripts tab so you can fix it accordingly
Different User Different Result
Since user ‘test’ did not ‘push’ his code in, the other user ‘admin’ will not be affected by it. The only way user admin can get this code if user ‘test’ does a ‘Push’ and then user ‘admin’ does a ‘Pull’. Lets see this in action now.
- Login as a user ‘admin’
- Go to Execution ‘New Amazon Execution’
- You can see in that execution that the test case ‘Add Star Wars to Cart’ has failed because user ‘test’ has ran it with his code
- Now run this same ‘Add Star Wars to Cart’ test case and observe the results
- The test case has passed because user ‘admin’ doesn’t have the code which user ‘test’ does
- Click on ‘Add Star Wars to Cart’ link in execution to open Test Details
- All action steps are shown as Passed and we see that that under Logs there is nothing (because the print statement is also in users ‘test’ code)
- Login as a user ‘test’
- Open ‘CheckMovieTVReleaseDecade.java’ modify the xpath code to be valid again but keep the print statement so your code will look like this:
package actions; import static java.lang.System.out; 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) { out.println("This is a hello from user test!"); WebElement element = Browser.Driver.findElement(By.xpath("//img[@alt=\""+params.get("Date range value")+"\"]")); if((Boolean)params.get("Check") && (element.getAttribute("src").contains("checkbox_unselected"))){ element.click(); } else if (!(Boolean)params.get("Check")&& element.getAttribute("src").contains("checkbox_selected")){ element.click(); } try{Thread.sleep(4000);}catch(InterruptedException e){} } }
- Click on Build Scripts button and then on Git Push button
- Login as a user ‘admin’
- Go to Scripts tab and open CheckMovieTVReleaseDecade.java
- Observe that print statement is not in the script yet
- Click on Git Pull button (computer with red arrow)
- Now the print statement that user ‘test’ pushed appeared and any future executions by user ‘admin’ will print that statement in the log when this action code is used
Post your comment on this topic.