Hello Friends,
This is one of the tutorials for Jira users who can use the Selenium script as an automation for adding the users in jira and updating the groups of the users. As you may know, adding the users in jira is a manual effort, and is a kind of repetitive task, so its always a ease to automate the repetitive work. Selenium is the one of the best alternative for removing the repetitive actions.
I have already covered the basics of Selenium in my previous post, click here to check. So, following is the java code which consists of the selenium script that will create the multiple users using the Selenium IDE.
[java]
package com.sample;
import com.thoughtworks.selenium.SeleneseTestCase;
public class AddUserInJira extends SeleneseTestCase
{
public void setUp() throws Exception
{
setUp(“http://localhost:8080/”, “*iexplore”);
// We instantiate and start the browser
}
public void testAddUserInJira() throws Exception
{
selenium.open(“/jira/login.jspa”);
selenium.selectFrame(“gadget-0”);
selenium.type(“id=login-form-username”, “jira_username”);
selenium.type(“id=login-form-password”, “jira_password”);
selenium.click(“id=login”);
selenium.waitForPageToLoad(“30000”);
selenium.selectWindow(“null”);
selenium.click(“id=admin_link”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“id=user_browser”);
selenium.waitForPageToLoad(“30000”);
selenium.type(“id=login-form-authenticatePassword”, “jira_password”);
selenium.click(“id=authenticateButton”);
selenium.waitForPageToLoad(“30000”);
//list of the users to be added in JIRA
String username = “test.user3,test.user4,test.user5,test.user6,test.user7”;
String[] list = null;
list = username.split(“,”);
for(int i=0; i<list.length; i++ )
String userName = list[i];
String fullName = userName.replace(“.”, ” “);
selenium.click(“id=add_user”);
selenium.waitForPageToLoad(“30000”);
selenium.type(“name=username”, userName);
selenium.type(“name=fullname”, fullName);
selenium.type(“name=email”, userName+”@portal.com”);
selenium.click(“name=sendEmail”);
selenium.click(“id=create_submit”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“id=editgroups_link”);
selenium.waitForPageToLoad(“30000”);
selenium.addSelection(“name=groupsToJoin”, “label=jira-group”);
selenium.click(“name=join”);
selenium.waitForPageToLoad(“30000”);
}
selenium.click(“id=home_link”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“link=Access more options”);
selenium.click(“id=log_out”);
selenium.waitForPageToLoad(“30000”);
}
public void tearDown()
{
//Added . Will be called when the test will complete
selenium.stop();
}
}
[/java]
For running this script you need to have the username and password of the user who has the administrator access over jira, else the script will fail. Here, we have taken the users list in an String array and then iterated the same using the for loop. However, you can use a code to take the users list from external source such as xml or Excel sheet, that will be really helpful.
Hope this will help you.
Regards,
Nikhil Naoghare.
Really a good website ,I like it.
You can see good blogs at cutehits.