コード例 #1
0
 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)
コード例 #2
0
    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)
コード例 #3
0
 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)
コード例 #4
0
    def createTrack(self,titleOfTrack,Imagefilepath,description,tagName,lessonname,expectedSuccessText):
        print "Creating track with one lesson contains Text Card"
        
        wait=WebDriverWait(driver, 60)
        wait.until(EC.visibility_of_element_located((By.XPATH,"//a[@href='/create/lessons']")))
        
        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"//a[@href='/create/tracks']")))
        print "Clicking on Track button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/tracks']").click()
        
        createTrackbutton=wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[2]/div/header/div/a")))
        
        createTrackbutton.click()
        
        print "Entering title"
        titlefield=wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='title']")))
        titlefield.send_keys(titleOfTrack)
        print "Title entered ::"+titleOfTrack
        
        driver.find_element_by_css_selector('input[type="file"]').send_keys(Imagefilepath)
        print "waiting to upload image"
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[2]/div/div/div[2]/div[1]/div[2]/div/div/div/div/div[1]/img")))
        print "Image uploaded"
        
        print "Entering Description"
        driver.find_element_by_xpath(".//*[@id='description']").send_keys(description)
        print "Description entered ::"+description 
        
        
        
        print "Adding tag"
        addTags=driver.find_element_by_xpath("//div[@class='Select-placeholder']")
        webdriver.ActionChains(driver).move_to_element(addTags).click().send_keys(tagName).perform()
        
        option=wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='react-select-2--option-0']")))
        webdriver.ActionChains(driver).move_to_element(option).click(option).perform()
        
        driver.find_element_by_xpath(".//*[@id='description']").send_keys(" ")
        
        
        print "Adding created lesson"
        
        print "Clicking on Add lessons button"
       
        driver.execute_script("window.scrollTo(0, 0);")
        addlessonbutton=driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div/button")
        addlessonbutton.click()
        
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div[2]/div/div/div[2]/div[2]/div/ul/li[1]/div[1]/div")))
        
        print "Searching for lesson in Add lessons pop up"
        driver.find_element_by_xpath(".//*[@id='search-lessons-in-modal']").send_keys(lessonname)
        
        searchedLesson=wait.until(EC.visibility_of_element_located((By.XPATH,"//li/div[2]/h4[.='"+lessonname+"']/../../div[1]/div")))
        searchedLesson.click()
        
        print "Lesson '"+lessonname+"' selected"
        print "Adding to Track"
        driver.find_element_by_xpath("html/body/div[2]/div/div/div[2]/div[3]/button[1]").click()
        
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[2]/div/div/div[2]/div[2]/div[1]/div/ul/li/div[2]/div/h4/div")))
        
        print "Checking added lesson is selected lesson from Pop up"
        lessonTextAddedToGrid=driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[2]/div/div/div[2]/div[2]/div[1]/div/ul/li/div[2]/div/h4/div").text

        if lessonTextAddedToGrid==lessonname:
            print "Selected Lesson is displayed in grid of tracks page"
        
        else:
            print "Lesson is not displayed"
            raise Exception
        
        print "Clicking on Publish Track button"
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[2]/div/div/div[2]/div[2]/div[3]/button").click()
        
        print "Verifying Success message is displaying"
        
        
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[2]/div/div/span")))
        actualSuccessText=driver.find_element_by_xpath(".//*[@id='content']/div/div[2]/div/div/span").text
        
        if actualSuccessText==expectedSuccessText:
            print "Success message '"+actualSuccessText+"' is displayed"
        else:
            print "failed to display expected success message"
            raise Exception
        
        
        print "Verifying Creates track '"+titleOfTrack+"' is displayed in Tracks grid"
        
        
      
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[2]/div[3]/div/ul/li[2]/a").click()
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"//tbody/tr/td[2]/a[.='"+titleOfTrack+"']")))
        
        trackInGrid=driver.find_element_by_xpath("//tbody/tr/td[2]/a[.='"+titleOfTrack+"']").text
        
        if trackInGrid==titleOfTrack:
            print "Track '"+trackInGrid+"' is displayed in grid"
        else:
            print "Track is not displayed in grid"
            raise Exception
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click()
コード例 #5
0
 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"
コード例 #6
0
    def createLessonTxtVidQue(self, lessonName, textCard, videoPath,
                              questionCard, ans1, ans2, timeToUploadVideo):

        print "\n\n----This Test case creates the Track with one lesson which contains Text, Video, Question card-----\n"
        wait = WebDriverWait(driver, 60)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "//a[@href='/create/lessons']")))

        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
                 )))

        print "Click on Create lesson button"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
        ).click()

        print "Verifying Create new lesson tab is displayed"

        #assert "Create a new lesson"==driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text
        if driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3"
                                        ).text == "Create a new lesson":
            print("Create a new lesson tab is displayed")
        else:
            print ""
            raise Exception

        # self.assertEqual("Create a new lesson", driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text)

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "html/body/div[2]/div/div/div[2]/div[2]/div")))

        print "Clicked on Blank lesson"
        driver.find_element_by_xpath(
            "html/body/div[2]/div/div/div[2]/div[2]/div").click()

        print "Creating New lesson With one Text card"

        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
            )))

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
        ).send_keys(lessonName)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saved']")))

        print "Entered lesson name ::" + lessonName

        objfor = CreateCampaignForTxtVidQuesLesson()

        #Text Card
        objfor.textCard(textCard)
        objfor.textCard(textCard)
        objfor.textCard(textCard)
        objfor.textCard(textCard)
        objfor.textCard(textCard)

        objfor.textCard(textCard)
        objfor.textCard(textCard)
        objfor.textCard(textCard)
        objfor.textCard(textCard)
        objfor.textCard(textCard)

        # Video card
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)

        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)
        objfor.videoCard(videoPath, timeToUploadVideo)

        #Question card
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)

        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)
        objfor.questionCard(questionCard, ans1, ans2)

        print "All Cards inserted"

        print "Publishing lesson"

        publishbutton = wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button"
            )))

        driver.execute_script("arguments[0].click();", publishbutton)

        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
            )))
        wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
            )))

        driver.find_element_by_xpath(
            "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
        ).click()
        print "Clicked on publish button"

        # verifying success message

        print "Verifying Success message"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div/div[2]/div/div/span[2]")))

        headerText = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[2]/div/div/span[2]").text
        print "Message '" + headerText + "' is displayed"

        if "You have successfully published" in headerText:
            print("Create a new lesson tab is displayed")
        else:
            print "Success message is not displayed"
            raise Exception

        print "Lesson published"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a"
        ).click()

        #Verifying created lesson is displayed in list

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "(//tbody/tr/td[2]/a[.='" + lessonName + "'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='" +
                                        lessonName + "'])[1]").is_displayed():

            print "\nLesson is displayed in Grid ::" + lessonName

        else:
            print "Lesson not displaying in grid"
            raise Exception

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click(
            )
コード例 #7
0
    def lessonWithImage(self,lessonName,Imagefilepath1):
        
        wait=WebDriverWait(driver, 60)
        wait.until(EC.visibility_of_element_located((By.XPATH,"//a[@href='/create/lessons']")))
        
        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[2]/div/header/div/button")))
     
        print "Click on Create lesson button"
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[2]/div/header/div/button").click()
        
        print "Verifying Create new lesson tab is displayed"
        
        #assert "Create a new lesson"==driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text
        if driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text == "Create a new lesson":
            print("Create a new lesson tab is displayed")
        else:
            print ""
            raise Exception
        
        # self.assertEqual("Create a new lesson", driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text)

        
               
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div[2]/div/div/div[2]/div[2]/div")))

        
        print "Clicked on Blank lesson"
        driver.find_element_by_xpath("html/body/div[2]/div/div/div[2]/div[2]/div").click()
        
        print "Creating New lesson With one Text card"
        
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea")))

        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea").send_keys(lessonName)
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']")))
        
        print "Entered lesson name ::"+lessonName
        
        print "Click on (+) icon"
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div/span").click()
        
        #Clicking on Image card
        driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[2]/div[1]").click()
        
        #Uploading image
        driver.find_element_by_css_selector('input[type="file"]').send_keys(Imagefilepath1)
        
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/img")))
        
        imageContainerlocator_after1upload= driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/img")
        
        if(imageContainerlocator_after1upload.is_displayed()):
            
            print 'Successfully uploaded the image1 file'
            
        else:
            print "Failed to upload the image1 file"
            raise Exception
        
        publishbutton=wait.until(EC.element_to_be_clickable((By.XPATH,"html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button")))
        
        driver.execute_script("arguments[0].click();",publishbutton)
        

        wait.until(EC.element_to_be_clickable((By.XPATH,"html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]")))

        driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]").click()
        print "Clicked on publish button"
        
        
        
        # verifying success message
        
        
        
        print "Verifying Success message"
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[2]/div/div/span[2]")))

        headerText=driver.find_element_by_xpath(".//*[@id='content']/div/div/div[2]/div/div/span[2]").text
        print "Message '"+headerText+"' is displayed"
        
        if "You have successfully published" in headerText:
            print("Create a new lesson tab is displayed")
        else:
            print "Success message is not displayed"
            raise Exception

        print "Lesson published"
        
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a").click()
        
        #Verifying created lesson is displayed in list
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"(//tbody/tr/td[2]/a[.='"+lessonName+"'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='"+lessonName+"'])[1]").is_displayed():
            
            print "Lesson is displayed in Grid ::"+lessonName
            
        else:
            print "Lesson not displaying in grid"
            raise Exception
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click()
コード例 #8
0
    def lessonWithText(self,lessonName,textCard):
        
        wait=WebDriverWait(driver, 60)
        wait.until(EC.visibility_of_element_located((By.XPATH,"//a[@href='/create/lessons']")))

        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div[3]/div[2]/div/header/div/button")))
     
        print "Click on Create lesson button"
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[2]/div/header/div/button").click()
        
        print "Verifying Create new lesson tab is displayed"
        
        #assert "Create a new lesson"==driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text
        if driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text == "Create a new lesson":
            print("Create a new lesson tab is displayed")
        else:
            print ""
            raise Exception
        
        # self.assertEqual("Create a new lesson", driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text)

        
               
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div[2]/div/div/div[2]/div[2]/div")))

        
        print "Clicked on Blank lesson"
        driver.find_element_by_xpath("html/body/div[2]/div/div/div[2]/div[2]/div").click()
        
        print "Creating New lesson With one Text card"
        
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea")))

        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea").send_keys(lessonName)
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']")))
        
        print "Entered lesson name ::"+lessonName
        
        print "Click on (+) icon"
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div/span").click()

        driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[1]/div[1]").click()
        
        textCardelement=driver.find_element_by_xpath("//div[@class='text']/div/div[1]/div")
        
        #Entering Text in Text card 
        
        webdriver.ActionChains(driver).move_to_element(textCardelement).click().send_keys(textCard).perform()
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']")))
        
        #Verifying entered text is displaying text card
        print "Verifying entered text is displaying text card"
        
        textAfterEntering=driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div/div[2]/div/div/div/div/div/div/span/span").text
        
        if textAfterEntering==textCard:
            print "Verified Text '"+textCard+"' is displayed in Text Card"
        else:
            print "Text not displayed in Text card"
            raise Exception
        
       
        publishbutton=wait.until(EC.element_to_be_clickable((By.XPATH,"html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button")))
        
        driver.execute_script("arguments[0].click();",publishbutton)
        
        time.sleep(2)
        wait.until(EC.element_to_be_clickable((By.XPATH,"html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]")))

        driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]").click()
        print "Clicked on publish button"
        
        
        
        # verifying success message
        
        
        
        print "Verifying Success message"
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[2]/div/div/span[2]")))

        headerText=driver.find_element_by_xpath(".//*[@id='content']/div/div/div[2]/div/div/span[2]").text
        print "Message '"+headerText+"' is displayed"
        
        if "You have successfully published" in headerText:
            print("Create a new lesson tab is displayed")
        else:
            print "Success message is not displayed"
            raise Exception

        print "Lesson published"
        
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a").click()
        
        #Verifying created lesson is displayed in list
        
        wait.until(EC.visibility_of_element_located((By.XPATH,"(//tbody/tr/td[2]/a[.='"+lessonName+"'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='"+lessonName+"'])[1]").is_displayed():
            
            print "Lesson is displayed in Grid ::"+lessonName
            
        else:
            print "Lesson not displaying in grid"
            raise Exception
        
        driver.find_element_by_xpath(".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click()
コード例 #9
0
    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)
コード例 #10
0
    def allCardsTwoTime(self, lessonName, textCard, Imagefilepath1, videoPath,
                        timeToUploadVideo, documentPath, timetoUploadDoc,
                        questionCard, ans1, ans2):

        print "\nCreating lesson with one card"
        wait = WebDriverWait(driver, 60)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "//a[@href='/create/lessons']")))

        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
                 )))

        print "Click on Create lesson button"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
        ).click()

        print "Verifying Create new lesson tab is displayed"

        #assert "Create a new lesson"==driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text
        if driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3"
                                        ).text == "Create a new lesson":
            print("Create a new lesson tab is displayed")
        else:
            print ""
            raise Exception

        # self.assertEqual("Create a new lesson", driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text)

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "html/body/div[2]/div/div/div[2]/div[2]/div")))

        print "Clicked on Blank lesson"
        driver.find_element_by_xpath(
            "html/body/div[2]/div/div/div[2]/div[2]/div").click()

        print "Creating New lesson"

        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
            )))

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
        ).send_keys(lessonName)

        print "Entered lesson name ::" + lessonName

        #Text Card
        objfore = CreateLessonDifferentCards()

        objfore.textCard(textCard)
        objfore.textCard(textCard)

        objfore.imageCard(Imagefilepath1)
        objfore.imageCard(Imagefilepath1)

        objfore.videoCard(videoPath, timeToUploadVideo)
        objfore.videoCard(videoPath, timeToUploadVideo)

        objfore.docCard(documentPath, timetoUploadDoc)
        objfore.docCard(documentPath, timetoUploadDoc)

        objfore.quesCard(questionCard, ans1, ans2)
        objfore.quesCard(questionCard, ans1, ans2)

        objfore.textCard(textCard)
        print "All Cards inserted"

        print "Publishing lesson"

        publishbutton = wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button"
            )))

        driver.execute_script("arguments[0].click();", publishbutton)

        wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
            )))

        driver.find_element_by_xpath(
            "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
        ).click()
        print "Clicked on publish button"

        # verifying success message

        print "Verifying Success message"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div/div[2]/div/div/span[2]")))

        headerText = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[2]/div/div/span[2]").text
        print "Message '" + headerText + "' is displayed"

        if "You have successfully published" in headerText:
            print("Create a new lesson tab is displayed")
        else:
            print "Success message is not displayed"
            raise Exception

        print "Lesson published"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a"
        ).click()

        #Verifying created lesson is displayed in list

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "(//tbody/tr/td[2]/a[.='" + lessonName + "'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='" +
                                        lessonName + "'])[1]").is_displayed():

            print "\nLesson is displayed in Grid ::" + lessonName

        else:
            print "Lesson not displaying in grid"
            raise Exception

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click(
            )
コード例 #11
0
    def lessonWithQuestion(self, lessonName, questionCard, ans1, ans2):
        wait = WebDriverWait(driver, 60)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "//a[@href='/create/lessons']")))

        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
                 )))

        print "Click on Create lesson button"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
        ).click()

        print "Verifying Create new lesson tab is displayed"

        #assert "Create a new lesson"==driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text
        if driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3"
                                        ).text == "Create a new lesson":
            print("Create a new lesson tab is displayed")
        else:
            print ""
            raise Exception

        # self.assertEqual("Create a new lesson", driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text)

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "html/body/div[2]/div/div/div[2]/div[2]/div")))

        print "Clicked on Blank lesson"
        driver.find_element_by_xpath(
            "html/body/div[2]/div/div/div[2]/div[2]/div").click()

        print "Creating New lesson With one question card"

        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
            )))

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
        ).send_keys(lessonName)

        print "Entered lesson name ::" + lessonName

        print "Click on (+) icon"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div/span"
        ).click()

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[5]/div[1]/div"
        ).click()

        print "Question card selected"

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, ".//*[@id='question-answer-input-0']")))
        print "Entering question"
        questionArea = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/p/textarea"
        )
        questionArea.send_keys(questionCard)
        print "Question entered ::"

        print "Entering first answer"
        driver.find_element_by_xpath(
            ".//*[@id='question-answer-input-0']").send_keys(ans1)
        print "First Answer entered "
        print "Entering Second answer"
        driver.find_element_by_xpath(
            ".//*[@id='question-answer-input-1']").send_keys(ans2)
        print "Second Answer entered "

        print "\nVerifying All the data entered is displaying in fields"

        if questionArea.text == questionCard:
            print "Question ::" + questionCard
        else:
            print "Question is not displayed"
            raise Exception

        if driver.find_element_by_xpath(
                ".//*[@id='question-answer-input-0']").text == ans1:
            print "Answer 1 ::" + ans1
        else:
            print "Answer 1 is not displayed"
            raise Exception

        if driver.find_element_by_xpath(
                ".//*[@id='question-answer-input-1']").text == ans2:
            print "Answer 2 ::" + ans2
        else:
            print "Answer 2 is not displayed"
            raise Exception

        #Verifying Correct answer displayed
        print "\nVerifying by default correct answer selected as A"

        if driver.find_element_by_xpath(
                "//input[@id='question-answer-correct-0']").is_selected():
            print "Verified Radio button for Correct answer A is selected"
        else:
            print "Radio button is not selected"
            raise Exception

        publishbutton = wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button"
            )))

        driver.execute_script("arguments[0].click();", publishbutton)

        wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
            )))

        driver.find_element_by_xpath(
            "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
        ).click()
        print "Clicked on publish button"

        print "\nVerifying Success message"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div/div[2]/div/div/span[2]")))

        headerText = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[2]/div/div/span[2]").text

        if "You have successfully published" in headerText:
            print "Message '" + headerText + "' is displayed"
        else:
            print "Success message is not displayed"
            raise Exception

        print "Lesson published"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a"
        ).click()

        print "\nVerifying lesson displayed in Grid"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "(//tbody/tr/td[2]/a[.='" + lessonName + "'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='" +
                                        lessonName + "'])[1]").is_displayed():

            print "Lesson is displayed in Grid ::" + lessonName

        else:
            print "Lesson not displaying in grid"
            raise Exception

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click(
            )
コード例 #12
0
    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)
コード例 #13
0
    def lessonWithDocument(self, lessonname, documentPath,
                           timeToUploaddocument, textCard):
        print "This is lesson with document"

        wait = WebDriverWait(driver, timeToUploaddocument)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "//a[@href='/create/lessons']")))

        print "Clicking on Lessons button from side menu"
        driver.find_element_by_xpath("//a[@href='/create/lessons']").click()
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
                 )))

        print "Click on Create lesson button"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[2]/div/header/div/button"
        ).click()

        print "Verifying Create new lesson tab is displayed"

        #assert "Create a new lesson"==driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text
        if driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3"
                                        ).text == "Create a new lesson":
            print("Create a new lesson tab is displayed")
        else:
            print ""
            raise Exception

        # self.assertEqual("Create a new lesson", driver.find_element_by_xpath("/html/body/div[2]/div/div/div[1]/h3").text)

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "html/body/div[2]/div/div/div[2]/div[2]/div")))

        print "Clicked on Blank lesson"
        driver.find_element_by_xpath(
            "html/body/div[2]/div/div/div[2]/div[2]/div").click()

        print "Creating New lesson With one Text card"

        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
            )))

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/h1/textarea"
        ).send_keys(lessonname)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saved']")))

        print "Entered lesson name ::" + lessonname

        print "Click on (+) icon"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div/span"
        ).click()

        #Clicking on Document card
        driver.find_element_by_xpath(
            "html/body/div/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[4]/div[1]/div"
        ).click()

        #Uploading Document
        print "Uploading Document"
        driver.find_element_by_css_selector('input[type="file"]').send_keys(
            documentPath)

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//label[@class='u-block card-media-upload-label']")))

        documentContainerlocator_afterupload = driver.find_element_by_xpath(
            "//label[@class='u-block card-media-upload-label']")

        if (documentContainerlocator_afterupload.is_displayed()):

            print "Successfully uploaded the Document file"

        else:
            print "Failed to upload the Document file"
            raise Exception

        o = CreateCampaignForDocumentLesson()
        o.textCard(textCard)
        '''driver.find_element_by_xpath("//div[@class='card-delete']/button").click()
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']")))
        '''
        print "Publishing lesson"

        publishbutton = wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button"
            )))

        driver.execute_script("arguments[0].click();", publishbutton)

        wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
            )))

        driver.find_element_by_xpath(
            "html/body/div/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
        ).click()
        print "Clicked on publish button"

        # verifying success message

        print "Verifying Success message"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 ".//*[@id='content']/div/div/div[2]/div/div/span[2]")))

        headerText = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[2]/div/div/span[2]").text
        print "Message '" + headerText + "' is displayed"

        if "You have successfully published" in headerText:
            print("Create a new lesson tab is displayed")
        else:
            print "Success message is not displayed"
            raise Exception

        print "Lesson published"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a"
        ).click()

        #Verifying created lesson is displayed in list

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, "(//tbody/tr/td[2]/a[.='" + lessonname + "'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='" +
                                        lessonname + "'])[1]").is_displayed():

            print "Lesson is displayed in Grid ::" + lessonname

        else:
            print "Lesson not displaying in grid"
            raise Exception

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click(
            )