Exemplo n.º 1
0
 def setUp(self):
     # 实例化webserver
     self.dir = webdriver.Chrome()
     lg = BasePage(self.dir)
     lg.load_page()
     self.dir.maximize_window()
     time.sleep(3)
Exemplo n.º 2
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")
Exemplo n.º 3
0
    def test_flexbook_page(self):

        # Selecting flexbook from explore
        explore = BasePage(self.driver)
        explore.selectItem(FlexbookPageLocators.FB_EXPLORE_MENU,
                           FlexbookPageLocators.FB_FLEXBOOK_OPTION)
        title = explore.el_get_title("FlexBooks® | CK-12 Foundation")
        print(title)
Exemplo n.º 4
0
 def verify(self, text):
     # com.mf.mfhr:id / main_guide_btn
     assert_loc = (By.XPATH, '//*[@text="%s"]' % text)
     time.sleep(2)
     if self.driver.find_element(*assert_loc):
         BasePage.logger(u"验证是否成功登录:True")
         return True
     else:
         BasePage.logger(u"验证是否成功登录:False")
         return False
 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
Exemplo n.º 6
0
 def setUp(self) -> None:
     self.dir = webdriver.Chrome()
     lg = BasePage(self.dir)
     lg.load_page()
     self.dir.maximize_window()
     time.sleep(2)
Exemplo n.º 7
0
 def __init__(self, driver):
     BasePage.__init__(self, driver)
Exemplo n.º 8
0
 def click_submit(self):
     BasePage.logger(u"点击登录按钮")
     self.driver.find_element(*self.submit_loc).click()
Exemplo n.º 9
0
    def input_passwd(self):  #,verificationCode):

        BasePage.logger(u"输入验证码")
        self.driver.find_element(*self.passwd_loc).send_keys("0000")
Exemplo n.º 10
0
 def input_username(self, userName):
     BasePage.logger(u"输入用户名: %s" % userName)
     self.driver.find_element(*self.account_loc).clear()
     self.driver.find_element(*self.account_loc).send_keys(userName)