def createCreatorUserLogin(self): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) first_sheet = book.sheet_by_name('CreateuserfromUI') print( "Fetching the First Name, LastName,Email,EmployeeId and password from Excel Sheet\n" ) # read a cell cell = first_sheet.cell(2, 3) Email = cell.value print Email cell = first_sheet.cell(2, 6) Password = cell.value print Password cell = first_sheet.cell(2, 7) NewPassword = cell.value print NewPassword wait = WebDriverWait(driver, 60) print "Grovo Sign-In page is displayed" print "Entering User name" driver.find_element_by_xpath(".//*[@id='username']").send_keys(Email) print "Entering Password" element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "password"))) element.send_keys(Password) element.send_keys(Keys.TAB) print "Clicking on Sign_In button" driver.find_element_by_xpath("//*[@id='submitButton']").click() wait.until(EC.visibility_of_element_located( (By.ID, "currentPassword"))) driver.find_element_by_id("currentPassword").send_keys(Password) print "Current Password is entered :" + Password driver.find_element_by_id("newPassword").send_keys(NewPassword) print "New Password is entered :" + NewPassword wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button"))) driver.find_element_by_xpath( "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button").click() wait.until( EC.visibility_of_element_located((By.ID, "global-header-search"))) print "Home Page is Loaded" print "Sign out " ele = driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div[1]/nav/div[2]/a/span[3]") driver.execute_script('arguments[0].click()', ele) elem = driver.find_element_by_xpath( "html/body/div/div/div[1]/div[2]/div[2]/a") driver.execute_script('arguments[0].click()', elem)
def userDeactivation(self): i = 0 for i in range(4): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) sheet1 = book.sheet_by_name('CreateuserfromUI') print("Fetching the LastName from Excel Sheet\n") #Read from Excel to search cell1 = sheet1.cell(i + 1, 1) searchfirstName = cell1.value print searchfirstName cell2 = sheet1.cell(i + 1, 2) searchlastName = cell2.value print searchlastName SearchName = searchfirstName + " " + searchlastName print SearchName #Clicking on Admin Menu from Grovo Application driver.find_element_by_xpath( ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a" ).click() wait = WebDriverWait(driver, 80) wait.until( EC.visibility_of_element_located((By.ID, "search-users"))) driver.find_element_by_id("search-users").send_keys(SearchName) wait = WebDriverWait(driver, 80) #To click on FirstName link wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[2]/div/div/div[4]/table/tbody/tr[1]" ))) driver.find_element_by_xpath( ".//*[@id='content']/div/div[3]/div[2]/div/div/div[4]/table/tbody/tr/td[1]/a" ).click() wait = WebDriverWait(driver, 80) driver.find_element_by_xpath( ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button" ).click() wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div[2]/div/div/div[2]/div[2]/button[1]"))) driver.find_element_by_xpath( "html/body/div[2]/div/div/div[2]/div[2]/button[1]").click() wait.until( EC.visibility_of_element_located((By.ID, "search-users"))) driver.find_element_by_xpath( ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]" ).click() print "All Created users are Deactivated"
def Logincreateuser(self): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) sheet1 = book.sheet_by_name('API testing') cell2 = sheet1.cell(1, 2) Currentpassword = cell2.value cell3 = sheet1.cell(1, 3) Newpassword = cell3.value wait = WebDriverWait(driver, 80) print "Grovo Sign-In page is displayed" print "Enter User name" driver.find_element_by_id("username").send_keys(email) print "Enter Password" element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "password"))) element.send_keys(Currentpassword) element.send_keys(Keys.TAB) print "Clicking on Sign_In button" driver.find_element_by_xpath("//*[@id='submitButton']").click() wait.until(EC.visibility_of_element_located( (By.ID, "currentPassword"))) driver.find_element_by_id("currentPassword").send_keys(Currentpassword) print "Current Password is entered :" + Currentpassword driver.find_element_by_id("newPassword").send_keys(Newpassword) print "New Password is entered :" + Newpassword wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button"))) driver.find_element_by_xpath( "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button").click() wait.until( EC.visibility_of_element_located( (By.XPATH, ".//*[@id='content']/div/div[1]/div/nav/div[1]/a[2]/span"))) print "Home Page is Loaded" expectedresult = "Home" expectedresult1 = "Library" actualresult = driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div/nav/div[1]/a[2]/span").text actualresult1 = driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div/nav/div[1]/a[3]/span").text if (expectedresult == actualresult): if (expectedresult1 == actualresult1): print "User is able to login and Dashboard is displayed.." else: print "User not able to login.." raise Exception print Exception wait = WebDriverWait(driver, 80) print "Sign out " ele = driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div[1]/nav/div[2]/a/span[3]") driver.execute_script('arguments[0].click()', ele) elem = driver.find_element_by_xpath( "html/body/div/div/div[1]/div[2]/div[2]/a") driver.execute_script('arguments[0].click()', elem)
def Logincreateuser(self): print "Reading data from excel sheet" book=xlrd.open_workbook(os.path.join('TestData.xlsx')) sheet1=book.sheet_by_name('API testing') cell2 = sheet1.cell(2,2) Currentpassword = cell2.value cell3 = sheet1.cell(2,3) Newpassword = cell3.value wait=WebDriverWait(driver, 80) print "Grovo Sign-In page is displayed" print "Enter User name" driver.find_element_by_id("username").send_keys(email) print "Enter Password" element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "password"))) element.send_keys(Currentpassword) element.send_keys(Keys.TAB) print "Clicking on Sign_In button" driver.find_element_by_xpath("//*[@id='submitButton']").click() wait.until(EC.visibility_of_element_located((By.ID,"currentPassword"))) driver.find_element_by_id("currentPassword").send_keys(Currentpassword) print "Current Password is entered :"+Currentpassword driver.find_element_by_id("newPassword").send_keys(Newpassword) print "New Password is entered :"+Newpassword wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div[2]/div/div/div[2]/div[1]/div[2]/button"))) driver.find_element_by_xpath("html/body/div[2]/div/div/div[2]/div[1]/div[2]/button").click() wait.until(EC.visibility_of_element_located((By.ID,"global-header-search"))) Home=driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[1]") Library = driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[2]") Create = driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[3]") Campaign = driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[4]") if(Home.is_displayed() and Library.is_displayed() and Create.is_displayed() and Campaign.is_displayed()): print "User with Creator Role is able to login and HOME,LIBRARY,CREATE and CAMPAIGN is displaying.." else: print"Home page not displayed" raise Exception print Exception print "Sign out " ele =driver.find_element_by_xpath(".//*[@id='content']/div/div[1]/div[1]/nav/div[2]/a/span[3]") driver.execute_script('arguments[0].click()',ele) elem=driver.find_element_by_xpath("html/body/div/div/div[1]/div[2]/div[2]/a") driver.execute_script('arguments[0].click()',elem)
def createTrackLessontwoTextImageVideoDocumentQuestionTag(self): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) first_sheet = book.sheet_by_name('CreateTag') print("Fetching the Attribute Name from Excel Sheet\n") # read a cell cell = first_sheet.cell(7, 2) TagName = cell.value print TagName cell = first_sheet.cell(7, 3) ExpectedSuccessMessage = cell.value print ExpectedSuccessMessage wait = WebDriverWait(driver, 60) wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a" ))) driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a" ).click() print "Clicked on admin icon" wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]"))) driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]").click( ) print "Clicked on Admin" driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[5]" ).click() print "Clicked on Tag" wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[2]/div/header/h1"))) print "Tag Page Loaded" driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/header/div/div/button").click( ) print "Clicked on Create Tag Button" wait.until(EC.visibility_of_element_located((By.ID, "add-tag-input"))) print "Verifying Create Tag Name field " if driver.find_element_by_id("add-tag-input").is_displayed(): print("Enter Tag name field is displayed") else: print "" raise Exception print "Verified Tag Name field" ele = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div/section[1]/div[1]/div/div[1]/div/input" ) webdriver.ActionChains(driver).move_to_element(ele).send_keys( TagName).perform() print "Entered Tag Name :" + TagName time.sleep(6) driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div/section[1]/div[1]/div/div[2]/button[1]" ).click() time.sleep(6) wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[2]/div/div/section[1]/div[1]/div" ))) ActualMessage = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div/section[1]/div[1]/div") ExpectedMessage = TagName + ExpectedSuccessMessage print "ExpectedMessage " + ExpectedMessage print( "Expected Success Message and Actual Success Message is Matching,Success Message Verified" ) print "Searching for the created Tag" wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[2]/div/div/section[1]/div[2]/div/div/input" ))) time.sleep(6) element = driver.find_element_by_name("tag-index-search") element.send_keys(TagName) driver.find_element_by_name("tag-index-search").send_keys(Keys.ENTER) time.sleep(6) print "Entered Tag Name for Search" wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[2]/div/div/section[2]/div/ul/li[1]" ))) print "Verifying the created Tag in the list" ele = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div/section[2]/div/ul/li[1]") print ele.text if driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div/section[2]/div/ul/li[1]" ).is_displayed(): print("Created Tag in the list") else: print "" raise Exception
def createTextAttributewithoutRequest(self): print "Reading data from excel sheet" book=xlrd.open_workbook(os.path.join('TestData.xlsx')) first_sheet = book.sheet_by_name('User_Attributes') print("Fetching the Attribute Name from Excel Sheet\n") # read a cell cell = first_sheet.cell(1,1) AttributeName = cell.value print AttributeName wait=WebDriverWait(driver, 60) wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a"))) driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a").click() print "Clicked on admin icon" wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]"))) driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]").click() print "Clicked on Admin" driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[1]").click() print "Clicked on User Attribute" driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[4]").click() wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div/div/div[3]/div[2]/div/header/h1"))) print "User attribute Page Loaded" driver.find_element_by_xpath("html/body/div/div/div[3]/div[2]/div/header/div/div").click() print "Clicked on Create attribute" wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div/div/div[3]/div[2]/div/header/h1"))) print "Add new custom attribute page loaded" print "verifying Details heading" if driver.find_element_by_xpath("html/body/div/div/div[3]/div[2]/div/div[2]/h2").is_displayed(): print("Details Heading is displayed") else: print "" raise Exception print "Verifying Attribute Name" ele =driver.find_element_by_xpath("html/body/div/div/div[3]/div[2]/div/div[2]/div[1]/div[1]/div/label").text if ele =="Attribute name": print("Attribute Name field is displayed") else: print "" raise Exception print "Entering attribute Name" driver.find_element_by_id("attribute-name").send_keys(AttributeName) print "Entered Attribute Name :"+AttributeName print "Verifying API Name field" if driver.find_element_by_id("attribute-api-name").is_displayed(): print("API Name field is displayed") else: print "" raise Exception print "Verifying Attribute Name and API NAme is matching" ele =driver.find_element_by_id("attribute-api-name").get_attribute('value') print ele if ele ==AttributeName: print("Attribute Name and API Name is Matching") else: print "" raise Exception print "Selected Text Type" driver.find_element_by_xpath("html/body/div/div/div[3]/div[2]/div/div[3]/div/div/div/div[1]/label").click() driver.execute_script("window.scrollTo(650, document.body.scrollHeight)") print "clicking on Save Button" driver.find_element_by_xpath("html/body/div/div/div[3]/div[2]/div/div[4]/button").click() wait.until(EC.visibility_of_element_located((By.XPATH,"//tbody/tr/td[1]/a[.='"+AttributeName+"']"))) print "Verifying the created attribute in the list" ele =driver.find_element_by_xpath("//tbody/tr/td[1]/a[.='"+AttributeName+"']") print ele.text if ele.text == AttributeName : print("Attribute Name and API Name is Matching") else: print "" raise Exception print "user Attribute Text Type without required option is Created" print "clicking on Home" first_sheet = book.sheet_by_name('Login_Credentials') print("Fetching the Attribute Name from Excel Sheet\n") # read a cell cell = first_sheet.cell(1,1) HomeURL = cell.value print HomeURL driver.get(HomeURL) wait.until(EC.visibility_of_element_located((By.ID,"global-header-search"))) print "Home Page Loaded"
def createLearnerAdminUser(self): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) first_sheet = book.sheet_by_name('CreateuserfromUI') print( "Fetching the First Name, LastName,Email,EmployeeId and password from Excel Sheet\n" ) # read a cell cell = first_sheet.cell(4, 1) FirstName = cell.value print FirstName cell = first_sheet.cell(4, 2) LastName = cell.value print LastName cell = first_sheet.cell(4, 3) Email = cell.value print Email cell = first_sheet.cell(4, 4) EmployeeId = cell.value print EmployeeId cell = first_sheet.cell(4, 5) DirectRole = cell.value print DirectRole cell = first_sheet.cell(4, 6) Password = cell.value print Password wait = WebDriverWait(driver, 60) wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a" ))) driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a" ).click() print "Clicked on admin icon" wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]"))) driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]").click( ) print "Clicked on Admin" driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[1]" ).click() print "clicked on Users" driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/header/div/div").click() print "Clicked on Add or editUser" driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/header/div").click() print "Clicked on Add An individual User" wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[2]/div/header"))) print "Verifying Add user Page" if driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/header").is_displayed(): print("Add user Page is displayed") else: print "" raise Exception print "Verifying First Name field" wait.until( EC.visibility_of_element_located( (By.ID, "create-edit-user-search-firstName"))) if driver.find_element_by_id( "create-edit-user-search-firstName").is_displayed(): print(" First Name field displayed") else: print "" raise Exception driver.find_element_by_id( "create-edit-user-search-firstName").send_keys(FirstName) print "FirstName is Entered ::" + FirstName print "Last NAme verifying" if driver.find_element_by_id( "create-edit-user-search-lastName").is_displayed(): print(" Last Name field displayed") else: print "" raise Exception driver.find_element_by_id( "create-edit-user-search-lastName").send_keys(LastName) print "Last Name is Entered ::" + LastName print "Email verifying" if driver.find_element_by_id( "create-edit-user-search-username").is_displayed(): print("Email field displayed") else: print "" raise Exception driver.find_element_by_id( "create-edit-user-search-username").send_keys(Email) print "Email is Entered ::" + Email print "Employee ID verifying" if driver.find_element_by_id( "create-edit-user-search-employeeId").is_displayed(): print("Employee ID field displayed") else: print "" raise Exception driver.find_element_by_id( "create-edit-user-search-employeeId").send_keys(EmployeeId) print "Employee ID is Entered ::" + EmployeeId print "Inherited Role Verifying" if driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div[2]/div/div/div[1]/div[6]/div" ).is_displayed(): print("Inherited Role field displayed") else: print "" raise Exception print "Selecting Learning Administrator in Direct Roles" dd1 = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div[2]/div/div/div[1]/div[5]/div/div/div" ) webdriver.ActionChains(driver).move_to_element(dd1).click().send_keys( DirectRole).perform() wait.until( EC.visibility_of_element_located( (By.XPATH, "//div[@role='option' and .='Learning Administrator']"))) ele = driver.find_element_by_xpath( "//div[@role='option' and .='Learning Administrator']") webdriver.ActionChains(driver).move_to_element(ele).click().perform() print "Password Field is Verifying" if driver.find_element_by_id( "create-edit-user-search-new-password").is_displayed(): print("Password field displayed") else: print "" raise Exception driver.find_element_by_id( "create-edit-user-search-new-password").send_keys(Password) print "Password is Entered ::" + Password wait.until( EC.visibility_of_element_located((By.XPATH, "//button[.='Add']"))) wait.until(EC.element_to_be_clickable((By.XPATH, "//button[.='Add']"))) driver.find_element_by_xpath("//button[.='Add']").click() print "Clicked on add button" wait.until( EC.visibility_of_element_located((By.XPATH, "//button[.='Save']"))) driver.find_element_by_xpath("//button[.='Save']").click() print "Clicked on Save" wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[2]/div/header/h1"))) print "Searching for the Created User" driver.find_element_by_id("search-users").send_keys(FirstName) wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[2]/div/div/div[4]/table/tbody/tr[1]" ))) ele = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[2]/div/div/div[4]/table/tbody/tr/td[1]" ).text if (ele == FirstName): print("Created User Verified") else: print "" raise Exception driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div/nav/div[2]/a/span[3]").click() print "Clicked on Account" driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div[2]/div[2]/a").click() print "Clicked on signOut Button" wait.until(EC.visibility_of_element_located((By.ID, "username")))
def createLearnerAdminLogin(self): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) first_sheet = book.sheet_by_name('CreateuserfromUI') print( "Fetching the First Name, LastName,Email,EmployeeId and password from Excel Sheet\n" ) # read a cell cell = first_sheet.cell(4, 3) Email = cell.value print Email cell = first_sheet.cell(4, 6) Password = cell.value print Password cell = first_sheet.cell(4, 7) NewPassword = cell.value print NewPassword wait = WebDriverWait(driver, 60) print "Grovo Sign-In page is displayed" print "Entering User name" driver.find_element_by_xpath(".//*[@id='username']").send_keys(Email) print "Entering Password" element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "password"))) element.send_keys(Password) element.send_keys(Keys.TAB) print "Clicking on Sign_In button" driver.find_element_by_xpath("//*[@id='submitButton']").click() wait.until(EC.visibility_of_element_located( (By.ID, "currentPassword"))) driver.find_element_by_id("currentPassword").send_keys(Password) print "Current Password is entered :" + Password driver.find_element_by_id("newPassword").send_keys(NewPassword) print "New Password is entered :" + NewPassword wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button"))) driver.find_element_by_xpath( "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button").click() wait.until( EC.visibility_of_element_located((By.ID, "global-header-search"))) #wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]"))) print "Home Page is Loaded" time.sleep(4) print "waiting For Admin" Admin = driver.find_element_by_xpath("//a[@href='/admin/tags']") driver.execute_script('arguments[0].click()', Admin) print "Clicked on Admin" wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[5]/div/ul/li[2]/a" ))) print "Home Page is Loaded" #driver.find_element_by_xpath("html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a").click() wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[1]"))) Home = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[1]") Library = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[2]") Create = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[3]") campaign = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[4]") Admin = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[5]") print "main found" Tags = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[5]/div/ul/li[1]/a" ) print "tags" + Tags.text ContentManager = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[5]/div/ul/li[2]/a" ) print "content" if ((Home.is_displayed()) and (Library.is_displayed()) and (Create.is_displayed()) and (campaign.is_displayed()) and (Admin.is_displayed()) and (Tags.is_displayed()) and (ContentManager.is_displayed())): print "User with Creator Role is able to login and HOME,LIBRARY,CREATE and CAMPAIGN is displaying.." else: print "Home page not displayed" raise Exception print "Sign out " ele = driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div[1]/nav/div[2]/a/span[3]") driver.execute_script('arguments[0].click()', ele) elem = driver.find_element_by_xpath( "html/body/div/div/div[1]/div[2]/div[2]/a") driver.execute_script('arguments[0].click()', elem)
def createAdminUserLogin(self): print "Reading data from excel sheet" book = xlrd.open_workbook(os.path.join('TestData.xlsx')) first_sheet = book.sheet_by_name('CreateuserfromUI') print( "Fetching the First Name, LastName,Email,EmployeeId and password from Excel Sheet\n" ) # read a cell cell = first_sheet.cell(3, 3) Email = cell.value print Email cell = first_sheet.cell(3, 6) Password = cell.value print Password cell = first_sheet.cell(3, 7) NewPassword = cell.value print NewPassword wait = WebDriverWait(driver, 60) print "Grovo Sign-In page is displayed" print "Entering User name" driver.find_element_by_xpath(".//*[@id='username']").send_keys(Email) print "Entering Password" element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "password"))) element.send_keys(Password) element.send_keys(Keys.TAB) print "Clicking on Sign_In button" driver.find_element_by_xpath("//*[@id='submitButton']").click() wait.until(EC.visibility_of_element_located( (By.ID, "currentPassword"))) driver.find_element_by_id("currentPassword").send_keys(Password) print "Current Password is entered :" + Password driver.find_element_by_id("newPassword").send_keys(NewPassword) print "New Password is entered :" + NewPassword wait.until( EC.visibility_of_element_located( (By.XPATH, "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button"))) driver.find_element_by_xpath( "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button").click() time.sleep(5) wait.until( EC.visibility_of_element_located((By.ID, "global-header-search"))) print "Home Page is Loaded" print "Home Page Verification For Master Admin" driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a" ).click() wait.until( EC.visibility_of_element_located(( By.XPATH, "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[1]/a[2]" ))) Home = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[1]") Library = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[2]") Create = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[3]") campaign = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[4]") Reports = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[5]") Admin = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]") Users = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[1]/a" ) Groups = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[2]/a" ) Roles = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[3]/a" ) Attributes = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[4]/a" ) Tags = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[5]/a" ) ContentManager = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[6]/a" ) Integrations = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[7]/a" ) Branding = driver.find_element_by_xpath( "html/body/div/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/div/ul/li[8]/a" ) if (Home.is_displayed() and Library.is_displayed() and (Create.is_displayed()) and campaign.is_displayed() and Reports.is_displayed() and Admin.is_displayed() and Users.is_displayed() and Groups.is_displayed() and Roles.is_displayed() and Attributes.is_displayed() and Tags.is_displayed() and ContentManager.is_displayed() and Integrations.is_displayed() and Branding.is_displayed()): print "User with Creator Role is able to login and HOME,LIBRARY,CREATE and CAMPAIGN is displaying.." else: print "Home page not displayed" raise Exception ele = driver.find_element_by_xpath( ".//*[@id='content']/div/div[1]/div[1]/nav/div[2]/a/span[3]") driver.execute_script('arguments[0].click()', ele) elem = driver.find_element_by_xpath( "html/body/div/div/div[1]/div[2]/div[2]/a") driver.execute_script('arguments[0].click()', elem)
def userCreationWithDirectRole(self): print "Reading data from excel sheet" book=xlrd.open_workbook(os.path.join('TestData.xlsx')) sheet1=book.sheet_by_name('API testing') print("Fetching the LastName from Excel to search") #Read from Excel to search cell1 = sheet1.cell(2,1) searchlastName = cell1.value #Clicking on Admin Menu from Grovo Application wait=WebDriverWait(driver,80) wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a"))) driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[2]/div[6]/a").click() wait.until(EC.visibility_of_element_located((By.ID,"search-users"))) driver.find_element_by_id("search-users").send_keys(searchlastName) #To click on FirstName link wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div/div/div[3]/div[2]/div/div/div[4]/table/tbody/tr[1]"))) driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[2]/div/div/div[4]/table/tbody/tr/td[1]/a").click() #To verify FirstName field print"Verify FirstName field" wait.until(EC.visibility_of_element_located((By.ID,"create-edit-user-search-firstName"))) firstNamelocator=driver.find_element_by_id("create-edit-user-search-firstName") firstName =firstNamelocator.get_attribute("value") if not firstName: print"FirstName field is empty" else: print"FirstName is present :" +firstName #To verify LastName field print"Verify LastName field" lastNamelocator =driver.find_element_by_id("create-edit-user-search-lastName") lastName=lastNamelocator.get_attribute("value") if not lastName: print"LastName field is empty" else: print"LastName is present : "+lastName #To verify Email field print"Verify Email field" emaillocator =driver.find_element_by_id("create-edit-user-search-username") global email email =emaillocator.get_attribute("value") if not email: print"Email field is empty" else: print"Email is present : "+email #To verify Employee ID field print"Verify Employee ID field" employeeidlocator =driver.find_element_by_id("create-edit-user-search-employeeId") employeeid=employeeidlocator.get_attribute("value") if not employeeid: print"Employee ID field is empty" else: print"Employee ID is present : "+employeeid #To verify Direct Roles field print"Verify Direct Roles field" wait.until(EC.visibility_of_element_located((By.XPATH,"(//span[@role='option'])[1]"))) DirectRoleslocator =driver.find_element_by_xpath("(//span[@role='option'])[1]") DirectRoles=DirectRoleslocator.text if not DirectRoles: print"Direct Roles field is empty" else: print"Direct Roles is present : "+DirectRoles #LogOut function driver.find_element_by_xpath(".//*[@id='content']/div/div[1]/div/nav/div[2]/a/span[3]").click() print "Clicked on SignOut Dropdown" driver.find_element_by_xpath(".//*[@id='content']/div/div[1]/div[2]/div[2]/a").click() print "Clicked on signOut Button" wait.until(EC.visibility_of_element_located((By.ID,"username")))