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(
            )
Exemple #2
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 = CreateLessonDifferentCards()

        #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)

        time.sleep(4)
        #Question card
        objfor.quesCard(questionCard, ans1, ans2)
        objfor.quesCard(questionCard, ans1, ans2)
        objfor.quesCard(questionCard, ans1, ans2)
        objfor.quesCard(questionCard, ans1, ans2)
        objfor.quesCard(questionCard, ans1, ans2)

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

        print "All Cards inserted"

        print "Publishing lesson"

        time.sleep(4)
        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"
            )))

        publishButton.click()

        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(
            )