def checkPbiDetails(self, pbi, idPbi): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='pbi%s'] a" % (pbiListTable, idPbi) info(css) if sel.is_element_present(css): sel.click(css) else: fail("Link to pbi not found") sel.wait_for_page_to_load(DEFAULT_TIMEOUT_MS) details = {'Title' : pbi.title, 'Description' : pbi.description, 'Priority' : 'Priority: ' + pbi.priority, 'DateCreation' : 'Created: ' + pbi.dateCreation } for elementId, value in details.iteritems(): css = "css=[id='pbiDetails%s']" % elementId text = sel.get_text(css) if text != value: fail("Wrong project.%s displayed: %s" % (elementId, text)) else: info("Content of %s OK" % elementId)
def checkSprintDetails(self, sprint, idSprint): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='sprint%s'] a" % (sprintListTable, idSprint) info(css) if sel.is_element_present(css): sel.click(css) else: fail("Link to sprint not found") sel.wait_for_page_to_load(DEFAULT_TIMEOUT_MS) details = {'Name' : sprint.name, 'DateFrom' : 'Date from: '+ sprint.dateFrom, 'DateTo' : 'Date to: ' + sprint.dateTo, 'Status' : 'Status: ' + sprint.status } for elementId, value in details.iteritems(): css = "css=[id='sprintDetails%s']" % elementId text = sel.get_text(css) if text != value: fail("Wrong project.%s displayed: %s" % (elementId, text)) else: info("Content of %s OK" % elementId)
def checkRowInSprintTable(self, sprint, idSprint, deleted=None): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='sprint%s']" % (sprintListTable, idSprint) info(css) if sel.is_element_present(css): info("New sprint visible in table") css = css + " td:nth-child(%s)" if sel.get_text(css % 1 + " h4 a") != sprint.name: fail("Invalid name") if sel.get_text(css % 2 ) != sprint.dateFrom: fail("Invalid date FROM") if sel.get_text(css % 3 ) != sprint.dateTo: fail("Invalid date TO") if sel.get_text(css % 6 ) != sprint.status: fail("Invalid status") else: if(deleted): info("Sprint deleted successfully") else: fail("New sprint didn't appear")
def login(self, role): sel = self.seleniumLibrary._selenium if( "%s" % role == "owner" ): sel.type( loginTB, owner ) sel.type( passwordTB, pswd ) self.clickOn( logIn ) elif( "%s" % role == "master" ): sel.type( loginTB, master ) sel.type( passwordTB, pswd ) self.clickOn( logIn ) elif( "%s" % role == "master2" ): sel.type( loginTB, 'sm2' ) sel.type( passwordTB, pswd ) self.clickOn( logIn ) elif( "%s" % role == "user" ): sel.type( loginTB, user ) sel.type( passwordTB, pswd ) self.clickOn( logIn ) elif( "%s" % role == "root" ): sel.type( loginTB, root ) sel.type( passwordTB, pswd ) self.clickOn( logIn ) elif( "%s" % role == "sp" ): sel.type( loginTB, 'sp' ) sel.type( passwordTB, pswd ) self.clickOn( logIn ) else: fail("Unknown user")
def checkProjectDetails(self, project, idProject): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='project%s'] a" % (projectListTable, idProject) info(css) if sel.is_element_present(css): sel.click(css) else: fail("Link to project not found") sel.wait_for_page_to_load(DEFAULT_TIMEOUT_MS) details = { 'Header' : project.key + " - " + project.name, 'Description' : project.description, 'Website' : 'Website: ' + project.website, 'Owner': 'Product owner: ' + project.owner, 'Version' : 'Version: ' + project.version } for elementId, value in details.iteritems(): css = "css=[id='projectDetails%s']" % elementId text = sel.get_text(css) if text != value: fail("Wrong project.%s displayed: %s" % (elementId, text)) else: info("Content of %s OK" % elementId)
def checkTitle(self, text) : sel = self.seleniumLibrary._selenium title = sel.get_title() if ("%s" % text in str(title)) : info("Title OK!") else: fail("Wrong title! Was %s, should be %s" % (sel.get_title(), text))
def checkRowInPbiTable(self, pbi, idPbi, deleted=None, attributes=None): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='pbi%s']" % (pbiListTable, idPbi) info(css) if(attributes != None): shift = len(attributes) else: shift = 0 print "SHIFT %s" % shift if sel.is_element_present(css): info("New pbi visible in table") css = css + " td:nth-child(%s)" if sel.get_text(css % 1 + " h4 a") != pbi.title: fail("Invalid name displayed") if sel.get_text(css % 2) != pbi.priority: fail("Invalid priority, was %s, should be %s" % (sel.get_text(css % 2), pbi.priority)) if sel.get_text(css % (5+shift)) != pbi.sprint: fail("Invalid sprint, was %s, should be %s" % (sel.get_text(css % (5+shift)), pbi.sprint)) if sel.get_text(css % (6+shift)) != pbi.status: fail("Invalid status, was %s, should be %s" % (sel.get_text(css % 6), pbi.status)) else: if(deleted): info("Pbi deleted successfully") else: fail("New pbi didn't appear")
def checkSpecyficTitle(self, viewName) : contents = {"" : "Home" , "index" : "Index" , "pbis" : "Backlog" , "new pbi" : "Add PBI" , "edit pbi" : "Edit PBI" , "teams" : "Teams" , "new team" : "Add Team" , "edit team" : "Edit Team" , "sprints" : "Sprints" , "new sprint" : "Add sprint" , "edit sprint" : "Edit Sprint" , "projects" : "Projects" , "new project" : "Add project" , "TEST" : "Project details" , "new atr" : "Add attribute" , "releases" : "Releases" , "new release" : "Add release" , "edit release" : "Edit release" , } sel = self.seleniumLibrary._selenium expectedTitle = contents[viewName] title = sel.get_title() if (expectedTitle in str(title)) : info("Title OK for %s " % viewName) else: fail("Wrong title for %s, was %s !" % (viewName, sel.get_title()))
def countRows(self, table, idColumn, idValue, expectedCount): query = "SELECT COUNT(%s) FROM scrumzu.%s WHERE %s = %s" % (idColumn, table, idColumn, idValue) rows = int(self.runQuery(query)[0][0]) expectedCount = int(expectedCount) if rows != expectedCount: fail('Got %s rows, should be %s' %(rows, expectedCount))
def waitFor(self, el): sel = self.seleniumLibrary._selenium for i in range(20) : if sel.is_element_present(el) : info("element appeared after %s" % i) break else : time.sleep(1) else : fail("element DID NOT appear")
def clickDialogWindowElement(self,element): sel = self.seleniumLibrary._selenium if(element == 'close filter'): el = filterClose elif(element == 'add filter'): el = filterAdd else: fail("Unknown element to click") sel.click(el)
def clickFilterActionButton(self, button): if(button == "select"): btn = filterSelectBtn elif(button == "clear"): btn = filterClearBtn elif(button == "run"): btn = filterRunBtn else: fail("Unknown button") self.clickOn(btn) info(btn + "clicked")
def checkRowInTeamTable(self, team, idTeam, deleted=None): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='team%s']" % (teamListTable, idTeam) info(css) if sel.is_element_present(css): info("New team visible in table") css = css + " td:nth-child(%s)" if sel.get_text(css % 1 + " h3 a") != team.key+' - '+team.name: fail("Invalid key and name") if sel.get_text(css % 1 + " p") != team.description: fail("Invalid description") if sel.get_text(css % 1 + " ul li a") != team.projectName: fail("Invalid project") else: if(deleted): info("Team deleted successfully") else: fail("New team didn't appear")
def clickReleaseActionButton(self, button): if(button == "new release"): btn = releaseAddBtn elif(button == "edit release"): btn = releaseEditBtn elif(button == "delete release"): btn = releaseDel elif(button == "submit form"): btn = submitForm else: fail("Unknown button") self.clickOn(btn) info(btn + "clicked")
def clickTeamActionButton(self, button): if(button == "new team"): btn = teamAddBtn elif(button == "edit team"): btn = teamEditBtn elif(button == "delete"): btn = teamDel elif(button == "submit form"): btn = submitForm else: fail("Unknown button") self.clickOn(btn) info(btn + "clicked")
def checkContent(self, viewName) : contents = {"pbis" : [pbiAddBtn , pbiEditBtn , pbiDelBtn , pbiSelectAllChbx] , "teams" : [teamAddBtn, teamEditBtn, teamDelBtn, teamSelectAllChbx] , "sprints" : [sprintAddBtn , sprintEditBtn , sprintDelBtn , sprintSelectAllChbx] , "projects" : [projectAddBtn , projectEditBtn , projectDelBtn , projectSelectAllChbx] , "filters" : [filterSelectBtn, filterClearBtn] , "filterDialogWindow" : [filterList , filterTable , filerTableLogic , filterTableColumn , filterTableOperator , filterTableValue , filterTableControls , filterNewName , filterSave] , "testAtr" : [projectAddAtr , projectDeleteAtr] , "releases" : [releaseAddBtn , releaseEditBtn , releaseDelBtn , releaseSelectAllChbx] , } for key in contents[viewName] : sel = self.seleniumLibrary._selenium if sel.is_element_present(key) : info("Element %s is present." % key) else : fail("Element %s not found!" % key)
def clickPbiActionButton(self, button): if(button == "new pbi"): btn = pbiAddBtn elif(button == "submit form"): btn = submitForm elif(button == "edit pbi"): btn = pbiEditBtn elif(button == "delete pbi"): btn = pbiDel elif(button == "mark as done"): btn = pbiMarkAsDone else: fail("Unknown button") self.clickOn(btn) info(btn + "clicked")
def clickProjectActionButton(self, button): if(button == "new project"): btn = projectAddBtn elif(button == "edit project"): btn = projectEditBtn elif(button == "delete project"): btn = projectDel elif(button == "submit form"): btn = submitForm elif(button == "add atr"): btn = projectAddAtr elif(button == "delete atr"): btn = projectDeleteAtr else: fail("Unknown button") self.clickOn(btn) info(btn + "clicked")
def clickSprintActionButton(self, button): if(button == "new sprint"): btn = sprintAddBtn elif(button == "edit sprint"): btn = sprintEditBtn elif(button == "delete sprint"): btn = sprintDel elif(button == "submit form"): btn = submitForm elif(button == "start sprint"): btn = sprintStart elif(button == "end sprint"): btn = sprintStop else: fail("Unknown button") self.clickOn(btn) info(btn + "clicked")
def goToPage(self, page): sel = self.seleniumLibrary._selenium if(page == 'pbis'): url = "/scrumzu/TEST/pbis/" elif(page == 'teams'): url = "/scrumzu/TEST/teams/" elif(page == 'sprints'): url = "/scrumzu/TEST/sprints/" elif(page == 'projects'): url = "/scrumzu/projects/" elif(page == 'releases'): url = "/scrumzu/TEST/releases/" elif(page == 'TEST'): url = "/scrumzu/TEST" else: fail("Unknown page given") sel.open(url) sel.wait_for_page_to_load(DEFAULT_TIMEOUT_MS)
def checkStatusInList(self, obj, idObj, expectedStatus): ''' Checks status of object with #id in proper table with objects list @param obj: object type, eg. sprint @param idObj: object id number in DB @param expectedStatus: expected obj status shown in table ''' sel = self.seleniumLibrary._selenium if(obj == 'pbi'): css = "css=table[id='%s'] tr[id='pbi%s'] td:nth-child(6)" % (pbiListTable, idObj) elif(obj == 'sprint'): css = "css=table[id='%s'] tr[id='sprint%s'] td:nth-child(6)" % (sprintListTable, idObj) else: fail("Unknown obj for status checking in list table") statusInTable = sel.get_text(css) if statusInTable != expectedStatus: fail("Invalid status, should be %s, but was %s" % (expectedStatus, statusInTable)) else: info("Status OK %s" % statusInTable)
def checkTeamDetails(self, team, idTeam): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='team%s'] a" % (teamListTable, idTeam) info(css) if sel.is_element_present(css): sel.click(css) else: fail("Link to team not found") sel.wait_for_page_to_load(DEFAULT_TIMEOUT_MS) details = {'Header' : team.key + ' - ' + team.name, 'Description' : team.description, 'Project' : 'Project: ' + team.projectName} for elementId, value in details.iteritems(): css = "css=[id='teamDetails%s']" % elementId text = sel.get_text(css) if text != value: fail("Wrong project.%s displayed: %s" % (elementId, text)) else: info("Content of %s OK" % elementId)
def checkUserRole(self, role): sel = self.seleniumLibrary._selenium css = "css=div[id=loginPanel] p b" if( role == 'owner' ): if sel.get_text( css ) != "po" : fail('User wrongly logged (product owner)') else: info('User logged as product owner') elif( role == 'master' ): if sel.get_text( css ) != "sm" : fail('User wrongly logged (scrum master)') else: info('User logged as scrum master') elif( role == 'user' ): if sel.get_text( css ) != "user" : fail('User wrongly logged (team member)') else: info('User logged as team member') else: fail('Unknown user') # def checkSprintStatusInList(self, idSprint, expectedStatus): # sel = self.seleniumLibrary._selenium # css = "css=table[id='%s'] tr[id='sprint%s'] td:nth-child(6)" % (sprintListTable, idSprint) # # statusInTable = sel.get_text(css) # # if statusInTable != expectedStatus: # fail("Invalid status, should be %s, but was %s" % (expectedStatus, statusInTable)) # else: # info("Status OK %s" % statusInTable)
def checkRowInReleaseTable(self, release, idRelease, deleted=None): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='release%s']" % (releaseListTable, idRelease) info(css) if sel.is_element_present(css): info("New release visible in table") css = css + " td:nth-child(%s)" if sel.get_text(css % 1 + " h4 a") != release.name: fail("Invalid name, was %s, should be %s" % (sel.get_text(css + "h4 a"), release.name)) if sel.get_text(css % 2 ) != release.dateFrom: fail("Invalid date FROM") if sel.get_text(css % 3 ) != release.dateTo: fail("Invalid date TO") else: if(deleted): info("Release deleted successfully") else: fail("New release didn't appear")
def checkHeader(self, expectedHeader) : sel = self.seleniumLibrary._selenium header = sel.get_text("css=h1") if header != expectedHeader: fail("Wrong header displayer, should be %s, but was %s" %(expectedHeader, header))
def checkRowInProjectTable(self, project, idProject, deleted=None): sel = self.seleniumLibrary._selenium css = "css=table[id='%s'] tr[id='project%s']" % (projectListTable, idProject) info(css) if sel.is_element_present(css): info("New project visible in table") css = css + " td:nth-child(%s)" if sel.get_text(css % 1 + " h3 a") != project.key+' - '+project.name: fail("Invalid key and name") if sel.get_text(css % 1 + " p" ) != project.description: fail("Invalid description") if sel.get_text(css % 1 + " ul li a" ) != project.website: fail("Invalid website") if sel.get_text(css % 1 + " ul li:nth-child(2)") != 'Version: '+project.version: fail("Invalid version") if sel.get_text(css % 1 + " ul li:nth-child(3)") != 'Product owner: '+project.owner: fail("Invalid product owner") else: if(deleted): info("Project deleted successfully") else: fail("New project didn't appear")