コード例 #1
0
    def test_checkTitle(self):
        title_of = BasePage(self.driver)
        test_dict = SFL.footer_links  # Parameters from the dictionary
        # Itrating the locators from the dictionary
        for i in test_dict:
            # converting the string to tuple
            locators = tuple(map(str, i.split(",")))
            title_of.el_click(locators)
            time.sleep(3)
            # Getting the Length of the window handles
            length = len(self.driver.window_handles)
            print(f'No. of Windows open: {length}')
            if length >= 2:
                parentWin = self.driver.window_handles[0]
                chldwin = self.driver.window_handles[1]
                self.driver.switch_to_window(chldwin)
                new_title = self.driver.title
                print(f'Expected: {test_dict[i]}')
                print(f'Actual: {new_title}')
                self.assertIn(test_dict[i], new_title,
                              "Page Titles don't Match")
                self.driver.close()
                self.driver.switch_to_window(parentWin)

            else:
                print("Only one window")
                new_title = self.driver.title
                print(f'Expected: {test_dict[i]}')
                print(f'Actual: {new_title}')
                self.assertIn(test_dict[i], new_title,
                              "Page Titles don't Match")
            self.driver.get("http://www.ck12.org")
コード例 #2
0
 def test_TC006_text_checkTopics(self):
     sub_topic = BasePage(self.driver)
     sub_list = STL.SUBJECTS
     sub_locators = STL.SUBJECTS_LOCATORS
     sub_topic_locators = STL.SUB_TOPIC_LOCATORS
     for i, j, k in zip(sub_list, sub_locators, sub_topic_locators):
         sub_topic.el_click(j)
         print(f'{i} Subject Clicked')
         topic = []
         topics = sub_topic.el_get_all(k)
         for m in topics:
             topic.append(m.text)
         print(f'{i} : {topic}')
         if i == 'SCIENCE':
             assert topic == STL.SCIENCE_TOPICS
             print('Science topics matches with the actual.')
         elif i == 'MATH':
             assert topic == STL.MATH_TOPICS
             print('Math topics matches with the actual.')
         else:
             return False