def test_onclick_popup_modal_and_presents_articles_titles(self):
        # self.create_database_record()

        # Visitor goes to home page and clicks on airplane word.
        self.browser.get(self.live_server_url)
        self.get_word('airplane').click()

        # Visitor waits until modal windows pop up.
        block = WebDriverWait(self.browser, 10)
        modal = block.until(expected_conditions.visibility_of_element_located((By.ID, 'word-details-modal')))

        # Visitor gets articles titles.
        self.check_for_title_in_article_table('airplane is faster than ship.')
        self.check_for_title_in_article_table('airplane crashed yesterday.')
        self.check_title_does_not_exist_in_article_table('rocket took off today morning.')

        # Visitor closes modal window, refreshes browser and clicks on rocket word.
        self.browser.find_element(By.XPATH, '//button[@class="btn btn-default"]').click()
        self.browser.refresh()
        self.browser.find_element_by_link_text('rocket').click()

        # Visitor waits until modal windows pop up.
        block = WebDriverWait(self.browser, 10)
        modal = block.until(expected_conditions.visibility_of_element_located((By.ID, 'word-details-modal')))

        # Visitor gets articles titles.
        self.check_title_does_not_exist_in_article_table('airplane is faster than ship.')
        self.check_title_does_not_exist_in_article_table('airplane crashed yesterday.')
        self.check_for_title_in_article_table('rocket took off today morning.')
Esempio n. 2
0
    def _do_signup(self):
        # Go to the webpage
        self.browser.get(self.url)
        wait = ui.WebDriverWait(self.browser, self.timeout)
        wait.until(expected_conditions.visibility_of_element_located(["id", "logo"]))

        # Log out any existing user
        if self.browser.find_elements_by_id("nav_logout"):
            nav = self.browser.find_element_by_id("nav_logout")
            if nav.is_displayed():
                self.browser.find_element_by_id("nav_logout").click()
                wait = ui.WebDriverWait(self.browser, self.timeout)
                wait.until(expected_conditions.title_contains(("Home")))

        # Go to the sign-up page
        wait = ui.WebDriverWait(self.browser, self.timeout)
        wait.until(expected_conditions.visibility_of_element_located(["id", "nav_signup"]))
        self.browser.find_element_by_id("nav_signup").click()
        wait = ui.WebDriverWait(self.browser, self.timeout)
        wait.until(expected_conditions.title_contains(("Sign up")))

        # Sign up (don't choose facility or group)
        wait = ui.WebDriverWait(self.browser, self.timeout)
        wait.until(expected_conditions.visibility_of_element_located(["id", "id_username"]))
        self.browser.find_element_by_id("id_username").send_keys(self.username)
        wait = ui.WebDriverWait(self.browser, self.timeout)
        wait.until(expected_conditions.visibility_of_element_located(["id", "id_password_first"]))
        self.browser.find_element_by_id("id_password_first").send_keys(self.password)
        self.browser.find_element_by_id("id_password_recheck").send_keys(self.password)
        self.browser.find_element_by_id("id_password_recheck").send_keys(Keys.TAB + Keys.RETURN)
        wait = ui.WebDriverWait(self.browser, self.timeout)
        wait.until(expected_conditions.visibility_of_element_located(["id", "logo"]))
    def test_medium_risk_obs(self):
        """
        Test that an 'urgently inform medical team' task
        is triggered after a medium NEWS score
        """
        medium_score = MEDIUM_RISK_SCORE_3_THREE_IN_ONE_EWS_DATA

        patients = self.patient_list_page.get_list_items()

        PatientPage(self.driver).select_patient(patients)
        PatientPage(self.driver).open_form(OPEN_OBS_MENU_NEWS_ITEM)
        PatientPage(self.driver).enter_obs_data(medium_score)

        ui.WebDriverWait(self.driver, 5).until(
            ec.visibility_of_element_located(CONFIRM_SUBMIT)
        )

        self.driver.find_element(*CONFIRM_SUBMIT).click()

        task = 'Urgently inform medical team'
        ui.WebDriverWait(self.driver, 5).until(
            ec.visibility_of_element_located(RELATED_TASK)
        )
        response = self.driver.find_element(*RELATED_TASK)

        self.assertEqual(task, response.text,
                         'Incorrect triggered action for medium risk ob')
Esempio n. 4
0
 def test_transPass(self):
     WebDriverWait(self.driver, 40).until(EC.visibility_of_element_located((By.NAME,'交易密码')))
     views=self.driver.find_elements_by_class_name('android.widget.EditText')
     views[0].send_keys('a1234567')
     views[1].send_keys('a1234567')
     self.driver.find_element_by_name('确定').click()
     WebDriverWait(self.driver, 40).until(EC.visibility_of_element_located((By.NAME,'恭喜您,交易密码设置成功!')))
    def test_shows_patient_data(self):
        """
        Test that a patient record shows data (graph/table) for the patient
        """
        patients = self.patient_list_page.get_list_items()

        PatientPage(self.driver).select_patient(patients)

        ui.WebDriverWait(self.driver, 1).until(
            ec.visibility_of_element_located(patient_page_locators.GRAPH_CHART)
        )

        patient_graph = self.driver.find_element(*
                                                 patient_page_locators
                                                 .GRAPH_CHART)

        self.assertEqual(patient_graph.is_displayed(), True, 'Graph not found')

        self.driver.find_element(*patient_page_locators
                                 .TABLE_TAB_BUTTON).click()

        ui.WebDriverWait(self.driver, 1).until(
            ec.visibility_of_element_located
            (patient_page_locators.TABLE_CONTAINER_TABLE))

        patient_table = self.driver.find_element(*
                                                 patient_page_locators
                                                 .TABLE_CONTAINER_TABLE)
        self.assertEqual(patient_table.is_displayed(), True, 'Table not found')
Esempio n. 6
0
def login(driver):
    print('Logging in into %s ...' % EDIT_URL)
    driver.get(EDIT_URL)
    print('...')

    elem = WebDriverWait(driver, 30).until(
        EC.visibility_of_element_located((By.NAME, 'Email'))
    )
    elem.send_keys(LOGIN)
    try:
        # two-field login
        elem = driver.find_element_by_name('Passwd')
        elem.send_keys(PASS)
    except NoSuchElementException:
        # single-field login
        elem.send_keys(Keys.ENTER)
        elem = WebDriverWait(driver, 30).until(
            EC.visibility_of_element_located((By.NAME, 'Passwd'))
        )
        elem.send_keys(PASS)

    elem.send_keys(Keys.ENTER)
    print('Submitting ...')

    WebDriverWait(driver, 30).until(lambda x: x.title[-len(EDIT_TITLE):] == EDIT_TITLE)
    print('...')
    def test_TL_001_timeline_settings_start_end_date(self):
        """
        Test : test_FI_001 To verify Start and End date check boxes.
        Description : .
        Revision:
        Author : Bijesh
        :return: None
        """

        self.timelinepage.get_time_line_settings_link.click()
        WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH,
                                                                 self.timelinepage._tl_settings_window_header_locator)))
        self.timelinepage.get_tl_settings_window_start_date_textbox.clear()
        self.timelinepage.get_tl_settings_window_start_date_textbox.send_keys(self.timelinepage.time_line_start_date)
        self.timelinepage.get_tl_settings_window_end_date_textbox.clear()
        self.timelinepage.get_tl_settings_window_end_date_textbox.send_keys(self.timelinepage.time_line_end_date)
        self.timelinepage.get_tl_settings_window_save_button.click()
        sleep(2)
        self.timelinepage.get_time_line_settings_link.click()
        WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH,
                                                                 self.timelinepage._tl_settings_window_header_locator)))
        actual_start_date = self.timelinepage.get_tl_settings_window_start_date_textbox.get_attribute('value').encode('utf-8')
        actual_end_date = self.timelinepage.get_tl_settings_window_end_date_textbox.get_attribute('value').encode('utf-8')
        exp_start_date = self.timelinepage.time_line_start_date.encode('utf-8')
        exp_end_date = self.timelinepage.time_line_end_date.encode('utf-8')
        self.timelinepage.get_tl_settings_window_close_button.click()
        if (actual_start_date == exp_start_date) and (actual_end_date == exp_end_date):
            self.assertTrue(True, "Start/End dates are not matching with the expected dates.")
        else:
            self.assertFalse(True, "Start/End dates are not matching with the expected dates.")
 def test_TL_003_timeline_settings_add_new_tags(self):
     """
     Test : test_FI_003 To verify that new tags added properly.
     Description : .
     Revision:
     Author : Bijesh
     :return: None
     """
     self.timelinepage.get_time_line_settings_link.click()
     WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH,
                                                              self.timelinepage._tl_settings_window_header_locator)))
     tag_count = 0
     try:
         if len(self.timelinepage.get_tl_settings_window_tags_delete_link)>=1:
             tag_count = len(self.timelinepage.get_tl_settings_window_tags_delete_link)
     except:
         pass
     self.timelinepage.get_tl_settings_window_start_date_textbox.clear()
     self.timelinepage.get_tl_settings_window_start_date_textbox.send_keys(self.timelinepage.time_line_start_date)
     self.timelinepage.get_tl_settings_window_end_date_textbox.clear()
     self.timelinepage.get_tl_settings_window_end_date_textbox.send_keys(self.timelinepage.time_line_end_date)
     self.timelinepage.get_tl_settings_window_tags_textbox.send_keys(self.timelinepage.time_line_tag_1)
     self.timelinepage.get_tl_settings_window_tags_add_button.click()
     self.timelinepage.get_tl_settings_window_save_button.click()
     sleep(2)
     self.timelinepage.get_time_line_settings_link.click()
     WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH,
                                                              self.timelinepage._tl_settings_window_header_locator)))
     tag_count_final = len(self.timelinepage.get_tl_settings_window_tags_delete_link)
     sleep(1)
     self.timelinepage.delete_all_tags()
     sleep(2)
     self.timelinepage.get_tl_settings_window_save_button.click()
     sleep(2)
     self.assertEqual(tag_count_final, tag_count+1,"New tag could not be added.")
Esempio n. 9
0
 def get_route(self):
     self.click_item(*Menu.SETTING)
     ui.WebDriverWait(self.DRIVER, 3).until(ec.visibility_of_element_located(ProductPath.PRO_SER))
     self.click_item(*ProductPath.PRO_SER)
     ui.WebDriverWait(self.DRIVER, 3).until(ec.visibility_of_element_located(ProductPath.PRODUCT))
     self.click_item(*ProductPath.PRODUCT)
     time.sleep(0.5)
Esempio n. 10
0
def add_students_bulk(driver, users):
    '''Add students to a recently created contest.'''

    driver.wait.until(
        EC.element_to_be_clickable(
            (By.CSS_SELECTOR,
             ('li.contestants > a')))).click()
    driver.wait.until(
        EC.visibility_of_element_located(
            (By.CSS_SELECTOR, 'div.contestants')))

    driver.wait.until(
        EC.visibility_of_element_located(
            (By.XPATH, (
                '//textarea[contains(@class, "contestants")]')))).send_keys(
                    ', '.join(users))
    driver.wait.until(
        EC.element_to_be_clickable(
            (By.CLASS_NAME, ('user-add-bulk')))).click()
    for user in users:
        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 '//table[contains(@class, "participants")]//a[text()="%s"]'
                 % user)))
Esempio n. 11
0
 def testExpectedConditionVisibilityOfElementLocated(self, driver, pages):
     pages.load("javascriptPage.html")
     with pytest.raises(TimeoutException):
         WebDriverWait(driver, 0.7).until(EC.visibility_of_element_located((By.ID, 'clickToHide')))
     driver.find_element_by_id('clickToShow').click()
     element = WebDriverWait(driver, 5).until(EC.visibility_of_element_located((By.ID, 'clickToHide')))
     assert element.is_displayed() is True
Esempio n. 12
0
    def setup_prevalence_chart(self, disease_progression_name, points, timeout=None):
        """Sets up the prevalence chart for the given Disease Progression. Returns the name of the relational function
        that contains the prevalence chart."""
        if timeout is None:
            timeout = self.default_timeout

        self.click_navbar_element('Disease Progression')
        # Once the Disease Progression choices come up, click the desired one
        WebDriverWait(self.selenium, timeout=timeout).until(
            EC.visibility_of_element_located((By.LINK_TEXT, disease_progression_name))
        ).click()

        # Once the latent period, etc. options come up, click to bring up the prevalence chart
        prevalence_options = WebDriverWait(self.selenium, timeout=timeout).until(
            EC.visibility_of_element_located((By.ID, 'id_disease_prevalence'))
        )
        prevalence_name = Select(prevalence_options).first_selected_option.text # remember its name
        prevalence_options.click()

        # Once the prevalence chart comes up, overwrite the old points with the new ones.
        FunctionsPanel(
            WebDriverWait(self.selenium, timeout=timeout).until(
                EC.visibility_of_element_located((By.ID, 'functions_panel'))
            )
        ).set_points(points)

        return prevalence_name
 def test_TL_004_timeline_settings_add_new_tag_wrong_value(self):
     """
     Test : test_FI_004 To verify that time line does not have any info if wrong tags has been added.
     Description : .
     Revision:
     Author : Bijesh
     :return: None
     """
     self.timelinepage.get_time_line_settings_link.click()
     WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH,
                                                              self.timelinepage._tl_settings_window_header_locator)))
     self.timelinepage.get_tl_settings_window_start_date_textbox.clear()
     self.timelinepage.get_tl_settings_window_start_date_textbox.send_keys(self.timelinepage.time_line_start_date)
     self.timelinepage.get_tl_settings_window_end_date_textbox.clear()
     self.timelinepage.get_tl_settings_window_end_date_textbox.send_keys(self.timelinepage.time_line_end_date)
     self.timelinepage.get_tl_settings_window_tags_textbox.send_keys(self.timelinepage.time_line_tag_2)
     self.timelinepage.get_tl_settings_window_tags_add_button.click()
     check_boxes_name = ["assessments","events","incidents", "field_interviews"]
     for item in check_boxes_name:
         self.timelinepage.check_box_enable(item)
     self.timelinepage.get_tl_settings_window_save_button.click()
     sleep(2)
     time_line_info = len(self.timelinepage.get_time_line_all_images)
     self.timelinepage.get_time_line_settings_link.click()
     WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH,
                                                              self.timelinepage._tl_settings_window_header_locator)))
     self.timelinepage.delete_all_tags()
     sleep(2)
     self.timelinepage.get_tl_settings_window_save_button.click()
     sleep(2)
     self.assertEqual(time_line_info, 1, "Tag could not be added properly.")
Esempio n. 14
0
    def wait_to_appear(self, item):
        """Wait for item to appear

           * If there are no spaces in item, waits for element with HTML id "item" to appear.
           * "first class1" - waits for first item with  HTML class "class1" to appear.
           * "2nd class1 class2" - waits for the 2nd item with HTML classes class1 and class2 to appear.
           * "last class1 class2" - waits for the last element with classes class1 and class2 to appear.
        """
        item = HitchSeleniumItem(item)
        if item.is_id:
            WebDriverWait(self.driver, self.wait_for_timeout).until(
                EC.visibility_of_element_located((By.ID, item.html_id))
            )
        else:
            full_xpath = """//*[{}][{}]""".format(
                " and ".join([
                    """contains(concat(' ', normalize-space(@class), ' '), ' {} ')""".format(
                        class_name
                    ) for class_name in item.html_classes]
                ),
                str(item.index + 1) if item.index >= 0 else "last()"
            )

            WebDriverWait(self.driver, self.wait_for_timeout).until(
                EC.visibility_of_element_located((By.XPATH, full_xpath))
            )
Esempio n. 15
0
    def user_Recharge(self,preMobileNo):
        WebDriverWait(self.driver,30).until(EC.visibility_of_element_located((By.NAME,u'充值'))) 
        self.click_myPage_recharge_Button()
        self.input_rechargeValue()
        self.choose_item_bank_check()
        self.click_recharge_Button()
        sleep(2)
        self.input_realName()
        self.intput_idCardNo()
 
        #切换输入法为latin输入法
        inputMethod.InputMethod().enableLatinIME()
        #输入银行卡号码
        self.input_bankCardNo()
        self.input_preMobileNo(preMobileNo)
        #设置appium输入法为当前输入法
        inputMethod.InputMethod().enableAppiumUnicodeIME()
        #点击"下一步"按钮,由于“下一步”的定为和点击,已经在loginPage中实现了,故直接调用即可
        loginPage.LoginPage(self.driver).click_next_step_Button()
        WebDriverWait(self.driver,30).until(EC.visibility_of_element_located((By.NAME,u'开通认证支付')))   
        self.input_verification_code()
        self.click_finish_binding_Button()
        #点击充值,输入验证码
        self.click_rechargeButton_and_input_verification_code()
        #点击“确认充值”按钮
        self.cilck_confirm_recharge_Button()
        WebDriverWait(self.driver,30).until(EC.visibility_of_element_located((By.NAME,u'恭喜您,充值成功!')))
        #点击返回按钮<,返回到我的页面
        loginPage.LoginPage(self.driver).click_back_Button()
Esempio n. 16
0
 def click_rectangle_button(self):
     """
     Clicks rectangle button.
     """
     if not is_element_present(self._driver, *self._rectangle_selected_button):
         self._wait.until(ec.visibility_of_element_located(self._rectangle_button)).click()
         self._wait.until(ec.visibility_of_element_located(self._rectangle_selected_button))
Esempio n. 17
0
 def click_metadata_tab(self):
     """
     Clicks the metadata tab
     """
     self._wait.until(ec.visibility_of_element_located(self._metadata_active_tab))
     self._driver.find_element(*self._metadata_tab).click()
     self._wait.until(ec.visibility_of_element_located(self._wnv_text_panel))
Esempio n. 18
0
 def checkWebPageRefreshTime(self, node, **kwargs ):
     """Check Web Page Refresh TimeOut"""
     LOG.info("Enables Connections...")
     LOG.info("Navigate to the Power Levels Page")
     sel = node.gui_login()
     #WebDriverWait(sel,30).until(EC.visibility_of_element_located((By.XPATH,getattr(self.sysConfAttr, 'power_levels_page'))))        
     WebDriverWait(sel,30).until(EC.visibility_of_element_located((By.XPATH,getattr(self.sysConfAttr, 'cross_connects_page'))))        
     #sel.find_element_by_xpath(getattr(self.sysConfAttr, 'power_levels_page')).click()
     sel.find_element_by_xpath(getattr(self.sysConfAttr, 'cross_connects_page')).click()
     #WebDriverWait(sel,30).until(EC.visibility_of_element_located((By.XPATH,getattr(self.sysConfAttr, 'power_page_visibility'))))
     WebDriverWait(sel,30).until(EC.visibility_of_element_located((By.CSS_SELECTOR,getattr(self.sysConfAttr, 'conn_tbl'))))
     #element = sel.find_element_by_xpath(getattr(self.sysConfAttr, 'powerlevel_element'))
     element = sel.find_element_by_css_selector(getattr(self.sysConfAttr, 'setport_label_map'))
     print "element : ", element
     refreshTime = 0
     ref_time = kwargs['refresh_time']
     timeout = int(ref_time)+10
     try:
         for x in range(0,timeout):
             print "inside loop"
             time.sleep(1)
             msg = element.is_displayed()
             refreshTime+=1
         #msg = element.is_displayed()
         #print "try msg : ", msg
         return msg
     except Exception as e:
         msg = str(e)
         print "except msg: ", msg
         return msg
 def test_help_modal_opens_and_closes(self):
     """
     The Help modal opens on click and closes on exit or blur
     """
     # Jane has some questions about the tool and sees a 'help' button in the menu. She
     # clicks it and is shown a window describing the Video Concept browser and a
     # point of contact at OEIT.
     self.student_log_in_complete()
     class_name = self.new_class_session.class_name
     
     side_nav_menu = self.browser.find_elements_by_class_name('nav-header')
     self.assertTrue(class_name, [nav_header.text for nav_header in side_nav_menu])
             
     # Check the help modal is present but not viewable
     help_modal = self.browser.find_element_by_id('help_modal')
     self.assertFalse(help_modal.is_displayed())
     
     help_link = self.browser.find_element_by_class_name('nav-help')
     help_link.click()
     
     modal_wait = WebDriverWait(self.browser, 5).until(
             EC.visibility_of_element_located((By.ID,'help_modal')))
     
     self.assertTrue(help_modal.is_displayed())
     modal_background = self.browser.find_element_by_class_name('reveal-modal-bg')
     self.assertTrue(modal_background.is_displayed())
     
     close_modal_link = self.browser.find_element_by_class_name('close-reveal-modal')
     close_modal_link.click()
     
     modal_wait = WebDriverWait(self.browser, 5).until(
             EC.invisibility_of_element_located((By.ID,'help_modal')))
     modal_wait = WebDriverWait(self.browser, 5).until(
             EC.invisibility_of_element_located((By.CLASS_NAME,'reveal-modal-bg')))
             
     self.assertFalse(help_modal.is_displayed())
     
     # Repeat but test close by clicking outside of the modal
     help_link.click()
     
     modal_wait = WebDriverWait(self.browser, 5).until(
             EC.visibility_of_element_located((By.ID,'help_modal')))
             
     self.assertTrue(help_modal.is_displayed())
     self.assertTrue(modal_background.is_displayed())
     
     builder = ActionChains(self.browser)    
     
     click_outside_modal = builder.move_to_element(modal_background) \
                                  .move_by_offset(-500, -300) \
                                  .click()
     
     click_outside_modal.perform()
     
     modal_wait = WebDriverWait(self.browser, 5).until(
             EC.invisibility_of_element_located((By.ID,'help_modal')))
     modal_wait = WebDriverWait(self.browser, 5).until(
             EC.invisibility_of_element_located((By.CLASS_NAME,'reveal-modal-bg')))
                     
     self.assertFalse(help_modal.is_displayed())
Esempio n. 20
0
 def click_batch_report_link(self):
     """
     Clicks Batch report link.
     """
     self._wait.until(ec.visibility_of_element_located(self._batch_report_link))
     click_element(self._driver, self._driver.find_element(*self._batch_report_link))
     self._wait.until(ec.visibility_of_element_located(self._generate_batch_report_button))
 def test_clicking_nav_menu_brings_confirmation_when_dirty(self):
     """
     When the admin canvas is "dirty" (the user has made unsaved changes), 
     clicking on the left-hand menu will bring up a confirmation box asking
     if the user really wants to discard her changes.
     """
     self.admin_login_and_open_existing_class_edit()
     self.open_topic_tree_one_level_with_activities()
     
     self.admin_updates_map()
     
     topic_link = self.browser.find_element_by_xpath(
             '//ul[@class="nav nav-tabs nav-stacked main-menu"]/li[2]/a[@class="view-tree"]')
     topic_link.click()
     
     modal_wait = WebDriverWait(self.browser, 3).until(
             EC.visibility_of_element_located((By.CLASS_NAME,'bootbox')))
     modal_wait = WebDriverWait(self.browser, 3).until(
             EC.visibility_of_element_located((By.CLASS_NAME,'modal-backdrop')))
     
     modal_body = self.browser.find_element_by_class_name('modal-body')
     self.assertEqual(
         'Really throw away all of your un-saved work?',
         modal_body.text)
     
     self.check_for_links('No!')
     self.check_for_links('Yes')
def submit_empty_form(expected_data):
    def _assert_has_no_errors():
        assert expected_data == output_data

    Arsenic().find_element_by_xpath('//button[@class="btn btn-success form-submit"]').click()
    try:
        WebDriverWait(Arsenic(), 10).until(
            EC.visibility_of_element_located((By.ID, 'state-given_names'))
        )
        WebDriverWait(Arsenic(), 10).until(
            EC.visibility_of_element_located((By.ID, 'state-display_name'))
        )
        WebDriverWait(Arsenic(), 10).until(
            EC.visibility_of_element_located((By.ID, 'state-research_field'))
        )
        output_data = {
            'given-name': Arsenic().find_element_by_id(
                'state-given_names'
            ).text,
            'display-name': Arsenic().find_element_by_id(
                'state-display_name'
            ).text,
            'reserach-field': Arsenic().find_element_by_id(
                'state-research_field'
            ).text
        }
    except (ElementNotVisibleException, WebDriverException):
        output_data = {}

    return ArsenicResponse(assert_has_no_errors_func=_assert_has_no_errors)
Esempio n. 23
0
def _load_assignments_list(browser, port, retries=5):
    # go to the correct page
    browser.get("http://localhost:{}/tree".format(port))

    def page_loaded(browser):
        return browser.execute_script(
            'return typeof IPython !== "undefined" && IPython.page !== undefined;')

    # wait for the page to load
    try:
        _wait(browser).until(page_loaded)
    except TimeoutException:
        if retries > 0:
            print("Retrying page load...")
            # page timeout, but sometimes this happens, so try refreshing?
            _load_assignments_list(browser, port, retries=retries - 1)
        else:
            print("Failed to load the page too many times")
            raise

    # wait for the extension to load
    _wait(browser).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#assignments")))

    # switch to the assignments list
    element = browser.find_element_by_link_text("Assignments")
    element.click()

    # make sure released, downloaded, and submitted assignments are visible
    _wait(browser).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#released_assignments_list")))
    _wait(browser).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#fetched_assignments_list")))
    _wait(browser).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#submitted_assignments_list")))
Esempio n. 24
0
def test_missing_exchange(exchange, browser, port, class_files, tempdir):
    # remove the exchange directory and fetched assignments
    rmtree(exchange)
    rmtree(os.path.join(tempdir, "Problem Set 1"))

    _load_assignments_list(browser, port)
    _wait_until_loaded(browser)

    # make sure all the errors are showing
    _wait(browser).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#released_assignments_list_error")))
    _wait(browser).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#fetched_assignments_list_error")))
    _wait(browser).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#submitted_assignments_list_error")))

    # verify that the dropdown list shows an error too
    default = browser.find_element_by_css_selector("#course_list_default")
    assert default.text == "Error fetching courses!"

    # recreate the exchange and make sure refreshing works as expected
    os.makedirs(exchange)

    # release an assignment
    run_nbgrader(["assign", "Problem Set 1", "--force"])
    run_nbgrader(["release", "Problem Set 1", "--course", "abc101", "--force"])

    # click the refresh button
    browser.find_element_by_css_selector("#refresh_assignments_list").click()
    _wait_until_loaded(browser)

    # wait for the released assignments to update
    rows = _wait_for_list(browser, "released", 1)
    assert rows[0].find_element_by_class_name("item_name").text == "Problem Set 1"
    assert rows[0].find_element_by_class_name("item_course").text == "abc101"
Esempio n. 25
0
    def add_file(self, path, node_url=None):
        """Add a file. Assumes that the test class is harnessed to a project"""
        node_url = node_url or self.project_url
        self.goto('files', node_url=node_url)

        wait(self.driver, 3).until(
            ec.visibility_of_element_located(
                (By.CSS_SELECTOR, 'div.container h3 a#clickable.dz-clickable')
            )
        )

        self.driver.execute_script('''
            $('input[type="file"]').attr('style', "");
        ''')

        #with WaitForFileUpload(self.driver, wait=5):

        ## Upload files
        #self.driver.find_element_by_css_selector(
        #    'div.container h3 A#clickable.dz-clickable'
        #).click()

        wait(self.driver, 3).until(
            ec.visibility_of_element_located(
                (By.CSS_SELECTOR, 'input[type="file"]')
            )
        )
        # Find file input
        field = self.driver.find_element_by_css_selector('input[type="file"]')

        # Enter file into input
        field.send_keys(path)
def CreatePage(driver, stackURL, cell):
    
    pageName = excelSheet[cell].value
    typePage = DeterminePage(driver, cell)  
    
    testID = "ctl00_ContentPlaceHolder1_ctl00_ctl00_menu_m2"
    #testID = GetID(driver, "ctl00_ContentPlaceHolder1_ctl00_ctl00_menu_m2", True)
    
    WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.ID, testID)))
    driver.find_element_by_id(testID).click()
    
    if(typePage == "Content"): num = "6"
    else: num = "7"
    
    testID = "ctl00_ContentPlaceHolder1_ctl00_ctl00_menu_m2_m" + num
    #testID = GetID(driver,"ctl00_ContentPlaceHolder1_ctl00_ctl00_menu_m2_m" + num, True)
    
    WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.ID, testID)))
    driver.find_element_by_id(testID).click()
    
    WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.ID, GetID(driver, "ctl00_ContentPlaceHolder1_ctl00_txtTitle", False))))    
    input = driver.find_element_by_id(GetID(driver, "ctl00_ContentPlaceHolder1_ctl00_txtTitle", False))
    input.send_keys(pageName)
    
    print(typePage)
    if(typePage == "Content"):
        CreateContentPage(driver, stackURL, cell)
    elif(typePage == "External"):
        CreateLinkPage(driver, stackURL, cell)
    elif(typePage == "File"):
        CreateFilePage(driver, stackURL, cell)
Esempio n. 27
0
 def click_batch_image_order_link(self):
     """
     Clicks Batch Image Order link.
     """
     self._wait.until(ec.visibility_of_element_located(self._batch_image_order_link))
     click_element(self._driver, self._driver.find_element(*self._batch_image_order_link))
     self._wait.until(ec.visibility_of_element_located(self._collection_modal))
Esempio n. 28
0
 def click_download_archive_of_fpos_link(self):
     """
     Clicks Download Archive of FPOs link.
     """
     self._wait.until(ec.visibility_of_element_located(self._download_archive_of_fpos_link))
     click_element(self._driver, self._driver.find_element(*self._download_archive_of_fpos_link))
     self._wait.until(ec.visibility_of_element_located(self._collection_modal))
Esempio n. 29
0
 def click_batch_keyword_apply_link(self):
     """
     Clicks Batch Keyword Apply link.
     """
     self._wait.until(ec.visibility_of_element_located(self._batch_keyword_apply_link))
     click_element(self._driver, self._driver.find_element(*self._batch_keyword_apply_link))
     self._wait.until(ec.visibility_of_element_located(self._collection_modal))
    def do_barcode_scan(self, patient_id):
        """
        Carry out a barcode scan with the patient id
        :param patient_id:
        """
        scan_item = self.driver.find_element(*BARCODE_SCAN_EL)
        scan_item.click()
        ui.WebDriverWait(self.driver, 5).until(
            ec.visibility_of_element_located((By.ID, 'patient_barcode')))

        ui.WebDriverWait(self.driver, 5).until(
            ec.visibility_of_element_located(
                (By.CSS_SELECTOR, '#patient_barcode .barcode_scan')))
        try:
            barcode_input = \
                self.driver.find_element(*BARCODE_SCAN_INPUT)
            self.driver.execute_script(
                "var scan = document.getElementsByName('barcode_scan')[0]; "
                "scan.setAttribute('value', ',{0},'); "
                "scan.textContent = ',{0},';".format(patient_id)
            )
            barcode_input.send_keys(Keys.ENTER)
            ui.WebDriverWait(self.driver, 5).until(
                ec.visibility_of_element_located((By.TAG_NAME, 'dl')))
        except NoSuchElementException:
            return False
        except TimeoutException:
            return False
        return True
Esempio n. 31
0
import time
import math
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium import webdriver

try:
    link = "http://suninjuly.github.io/explicit_wait2.html"
    browser = webdriver.Chrome()
    browser.get(link)

    WebDriverWait(browser, 12).until(
        ec.text_to_be_present_in_element((By.ID, "price"), '100'))
    browser.find_element_by_id('book').click()
    WebDriverWait(browser,
                  2).until(ec.visibility_of_element_located((By.ID, 'answer')))
    x = browser.find_element_by_id("input_value").text
    browser.find_element_by_id('answer').send_keys(
        str(math.log(abs(12 * math.sin(int(x))))))
    browser.find_element_by_xpath('//button[text()="Submit"]').click()

finally:
    time.sleep(10)
    browser.quit()
Esempio n. 32
0
 def __get__(self, obj, owner):
     driver = obj.driver
     wait_time = obj.wait_time
     return WebDriverWait(driver, wait_time).until(
         EC.visibility_of_element_located(self.locator))
Esempio n. 33
0
 def waitElement(self, element_type, wait_sth):
     self.wait = WebDriverWait(self.d, 20)
     ele = self.wait.until(
         EC.visibility_of_element_located((element_type, wait_sth)))
     return ele
Esempio n. 34
0
 def get_element(self, *locator):
     return WebDriverWait(self.driver, 50).until(ec.visibility_of_element_located((locator[0], locator[1])))
 def click_confirm(self, time=100):
     self.driver.find_element(By.XPATH, self.confirm_locator).click()
     return WebDriverWait(self.driver, time).until(
         expected_conditions.visibility_of_element_located((By.XPATH, self.updated_email_modal_locator)),
         message=f"Confirm modal {self.updated_email_modal_locator} not found")
Esempio n. 36
0
 def wait_for_results(self):
     WebDriverWait(self._driver, 10).until(
         expected_conditions.visibility_of_element_located((By.ID, "query-results"))
     )
Esempio n. 37
0
now = datetime.now()

cap = DesiredCapabilities().FIREFOX
cap["marionette"] = True

options = FirefoxOptions()
options.binary = BINARY
options.add_argument("--headless")
options.add_argument("--window-size=1920x1080")
driver = webdriver.Firefox(capabilities = cap, executable_path = WEB_DRIVER_PATH, options = options)
driver.get(FINAL_URL)
print('Initiated headless')
print('200')

try:
    WebDriverWait(driver, TIMEOUT).until(EC.visibility_of_element_located((By.XPATH, "//td[@class='ylwbg']")))
    print("Page successfully loaded")
except TimeoutException:
    print("Timed out waiting for page to load")
    driver.quit()


bs_obj = BSoup(driver.page_source, 'html.parser')
rows = bs_obj.find('table', {'id':'octable'}).find('tbody').find_all('tr')
col_names = bs_obj.find('table', {'id':'octable'}).find('thead').find_all('tr')[1]
current_ticker = bs_obj.find_all('table')[0].find('tbody').find('tr').find_all('td')[1].find('div').find_all('span') 

bnf_price = current_ticker[0].find('b').text
time = current_ticker[1].text

#Cleaning up
Esempio n. 38
0
#coding=utf-8
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://www.imooc.com/')
element = driver.find_element_by_id("js-sing-btn")
element.click()
EC.presence_of_element_located
'''
LOCATOR = (By,ID,'username')
EC.visibility_of_element_located(LOCATOR)
'''

driver.find_element_by_name('email').send_keys('18302166037')
driver.find_element_by_name('password').send_keys('hhh8023')
driver.find_element_by_xpath('//*[@id="signup-form"]/div[5]/input').click()
#登录按钮可以用css层级定位
#driver.find_elements_by_css_selector(".rlf-group>.moco-btn").click()
time.sleep(2)
#浏览器console中输入:document.getElementsByName('password')[0]可查看元素
#element = driver.find_element_by_name('password')[0]
#element.send_keys('test')

#driver.find_element_by_link_text('Unity3d粒子系统射击特效')
#driver.find_element_by_partial_link_text('Unity3d').click()
#elements时需要加下标
#driver.find_elements_by_partial_link_text()[]
Esempio n. 39
0
 def select_startTime(self, strt):
     time.sleep(3)
     WebDriverWait(self.browser, 20).until(EC.visibility_of_element_located(self.dropdown_startTime))
     select = Select(self.browser.find_element(*self.dropdown_startTime))
     select.select_by_visible_text(strt)
Esempio n. 40
0
 def wait_until_and_get_elem_by_css(self, elem) -> WebElement:
     return WebDriverWait(self.driver, 30, 0.1).until(EC.visibility_of_element_located((By.CSS_SELECTOR, elem)))
Esempio n. 41
0
 def find(self, locator) -> WebElement:
     ele = WebDriverWait(self.driver, 10).until(ec.visibility_of_element_located(locator))
     # ele = self.driver.find_element(*locator)
     return ele
Esempio n. 42
0
    def test_account_link(self):
        WebDriverWait(self.driver, 10).until(lambda s: s.find_element_by_id('select-language').get_attribute('length') == 3)

        account = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.LINK_TEXT, 'ACCOUNT')))
        account.click()
Esempio n. 43
0
    def creditcard_payment_two(browser, req):
        """
        支付页面有两种形式,此为输入名字和email的形式
        有航空指南的一定是跨国,必填追加信息.支付页面是填email.
        无航空指南的韩国国内行程乘客信息无追加信息仅有折扣一栏.会弹出信用卡窗口,支付页面选择国外卡,填email.
        :param browser:
        :param req:
        :return:
        """
        WebDriverWait(browser, 50).until(
            EC.visibility_of_element_located((By.ID, 'foreign_credit_card')))
        browser.find_element_by_id(
            "foreign_credit_card").find_element_by_class_name(
                "iradio_minimal-red").click()
        creditCardInfo = req.creditCardInfo
        name = creditCardInfo["name"]
        firstName = name.split(" ")[0]
        lastName = name.split(" ")[1]
        linkEmail = booker_config.get('linkManInfo', 'email')
        browser.find_element_by_id("krp_last_name").send_keys(lastName)
        browser.find_element_by_id("krp_first_name").send_keys(firstName)
        browser.find_element_by_id("krp_email").send_keys(linkEmail)
        # 下滑到底部
        js = "var q=document.documentElement.scrollTop=100000"
        browser.execute_script(js)
        ch = browser.current_window_handle
        browser.find_element_by_id("PNWBA00014").find_element_by_class_name(
            "icheckbox_minimal-red").click()
        browser.find_element_by_id("PNWBA00014").find_element_by_class_name(
            "btn-color04").click()
        t = booker_config.getint('eastarjet', 'time')
        time.sleep(t)
        # 所有的window handles
        wh = browser.window_handles
        # 在所有窗口中查找弹出窗口
        browser.switch_to.window(wh[-1])
        time.sleep(t)
        cardNumber = creditCardInfo["cardNumber"]
        cutCardNum = cardNumber.split(" ")
        browser.find_element_by_id("viewcardno1").send_keys(cutCardNum[0])
        browser.find_element_by_id("viewcardno2").send_keys(cutCardNum[1])
        browser.find_element_by_id("viewcardno3").send_keys(cutCardNum[2])
        browser.find_element_by_id("viewcardno4").send_keys(cutCardNum[3])
        cvv = creditCardInfo["cvv"]
        browser.find_element_by_name("cvv").send_keys(cvv)
        validityPeriod = creditCardInfo["validityPeriod"]
        date = validityPeriod.split("/")
        # 下拉按钮:月份,年份
        browser.find_element_by_id("monthtd").click()
        a = browser.find_element_by_id("monthtd").find_element_by_class_name(
            "sbOptions")
        time.sleep(t)
        a.find_elements_by_tag_name("li")[int(
            date[0])].find_element_by_tag_name("a").click()
        browser.find_element_by_id("yeartd").click()
        time.sleep(t)
        YY = browser.find_element_by_id("yeartd").find_element_by_class_name(
            "sbOptions").find_elements_by_tag_name("li")
        for item in YY:
            YY_value = item.find_element_by_tag_name("a").text
            if date[1] in YY_value:
                item.click()
                break
        # 名字
        browser.find_element_by_id("fname").send_keys(firstName)
        browser.find_element_by_id("lname").send_keys(lastName)
        browser.find_element_by_class_name("footer_btn").click()
        time.sleep(2)

        # 注:多次验证发现情形不同的情况下,想选择的按钮id,class有变,故而用以下形式
        bizhong = browser.find_element_by_id(
            "confirmText").find_elements_by_tag_name("label")
        for item in bizhong:
            bizhong_type = item.text[0]
            if bizhong_type == "GBP":  # 有可能无此项
                continue
            item.click()

        browser.find_element_by_name("agree").click()
        browser.find_element_by_class_name("btn-primary").click()
Esempio n. 44
0
 def wait_until_and_get_elem_by_xpath(self, elem) -> WebElement:
     return WebDriverWait(self.driver, 15, 0.1).until(EC.visibility_of_element_located((By.XPATH, elem)))
Esempio n. 45
0
        百度高级搜索

"""
from time import sleep

from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.get("https://www.baidu.com/")
locator = "//div[@id='u1']/a[text()='设置']"
WebDriverWait(driver, 10, 0.5).until(EC.visibility_of_element_located((By.XPATH, locator)))
driver.find_element_by_xpath(locator).click()

locator2 = '//a[text()="高级搜索"]'
# 等待元素可见
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, locator2)))
driver.find_element_by_xpath(locator2).click()


# Select类使用
# 1、实例化类。参数为Select对象
locator3 = "//select[@name='ft']"
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, locator3)))

select = Select(driver.find_element_by_xpath(locator3))
sleep(1)
Esempio n. 46
0
    def fill_in_information(browser, req):
        WebDriverWait(browser, 50).until(
            EC.visibility_of_element_located((By.ID, "reserver_last_name")))
        # 同意协议
        all_agree = browser.find_element_by_id("PNWBA00013").find_element_by_id('divTerms').\
            find_elements_by_class_name("term")
        all_agree_list = []
        t = booker_config.getint('eastarjet', 'time')
        time.sleep(t)
        for agree_option in all_agree:
            all_agree_list.append(agree_option)
            agree_option.find_elements_by_class_name(
                'iradio_minimal-red')[0].click()
        # 下滑到一半
        js = "var q=document.documentElement.scrollTop=800;$('.r_birth').find('input').attr('type','text')"
        browser.execute_script(js)
        browser.find_elements_by_class_name("tel")[
            1].find_element_by_class_name("icheckbox_minimal-red").click()
        # 乘客信息填写
        passengers = browser.find_element_by_class_name(
            "grouping").find_elements_by_tag_name("tbody")
        i = 0
        a = 0
        for index, passenger in enumerate(passengers):
            if index % 2 == 0:
                if req.passengers[i]["gender"] == "F":
                    passenger.find_element_by_class_name(
                        "gender").find_elements_by_tag_name(
                            "li")[1].find_element_by_class_name(
                                "iradio_minimal-red").click()
                elif req.passengers[i]["gender"] == "M":
                    passenger.find_element_by_class_name(
                        "gender").find_elements_by_tag_name(
                            "li")[0].find_element_by_class_name(
                                "iradio_minimal-red").click()
                passenger.find_element_by_name("last_name").send_keys(
                    req.passengers[i]["lastName"])
                passenger.find_element_by_name("first_name").send_keys(
                    req.passengers[i]["firstName"])
                birthday = req.passengers[i]["birthday"].split("-")
                year = birthday[0]
                month = birthday[1]
                day = birthday[2]
                brd = passenger.find_element_by_class_name(
                    "r_birth").find_elements_by_tag_name("input")
                brd[0].send_keys(year)
                brd[1].send_keys(month)
                brd[2].send_keys(day)
                i += 1
        # 追加信息
        # 护照国家
            if index % 2 == 1:
                if len(all_agree_list) > 2:
                    passenger.find_element_by_class_name(
                        'c1').find_element_by_class_name("selectBox").click()
                    nationlity = passenger.find_element_by_class_name(
                        'c1').find_elements_by_tag_name("a")
                    for item in nationlity:
                        if req.passengers[a][
                                "nationality"] == item.get_attribute(
                                    "data-value"):
                            item.click()
                            break
                    # 护照信息
                    passenger.find_element_by_name('passport_num').send_keys(
                        req.passengers[a]["cardNum"])
                    # 护照到期时间
                    card_ex = req.passengers[a]["cardExpired"].split("-")
                    card_ex_year = card_ex[0]
                    card_ex_month = card_ex[1]
                    card_ex_day = card_ex[2]
                    passenger.find_element_by_class_name(
                        "p_birth").find_elements_by_class_name(
                            "selectBox")[0].click()
                    passport_year = passenger.find_element_by_class_name(
                        'passport_year').find_elements_by_tag_name('a')
                    for item in passport_year:
                        if card_ex_year == item.text:
                            item.click()
                            break
                    passenger.find_element_by_class_name(
                        "p_birth").find_elements_by_class_name(
                            "selectBox")[1].click()
                    passport_month = passenger.find_element_by_class_name(
                        'passport_month').find_elements_by_tag_name('a')
                    for item in passport_month:
                        if card_ex_month == item.text:
                            item.click()
                            break
                    passenger.find_element_by_class_name(
                        "p_birth").find_elements_by_class_name(
                            "selectBox")[2].click()
                    passport_day = passenger.find_element_by_class_name(
                        'passport_day').find_elements_by_tag_name('a')
                    for item in passport_day:
                        if card_ex_day == item.text:
                            item.click()
                            break
                    # 发行护照国家
                    passenger.find_element_by_class_name(
                        'c2').find_element_by_class_name("selectBox").click()
                    all_issueplace = passenger.find_element_by_class_name(
                        'c2').find_elements_by_tag_name("a")
                    for item in all_issueplace:
                        if req.passengers[a][
                                "cardIssuePlace"] == item.get_attribute(
                                    "data-value"):
                            item.click()
                            break
                    a += 1
                else:
                    id_discount = passenger.find_element_by_class_name('identity').\
                        find_element_by_class_name("selectBox")
                    id_discount.click()
                    id_discount.find_elements_by_tag_name(
                        "li")[0].find_element_by_tag_name("a").click()

        # 确定
        p = booker_config.getint('eastarjet', 'passenger_time')
        browser.execute_script("window.scrollBy(0,document.body.scrollHeight)",
                               "")
        time.sleep(3)
        browser.find_element_by_id("PNWBA00013").find_element_by_class_name(
            'btn-color04').click()
        time.sleep(p)
        browser.execute_script("window.scrollBy(0,document.body.scrollHeight)",
                               "")
        time.sleep(3)
        browser.find_element_by_id('PNWBA00033').find_element_by_class_name(
            'btn-color04').click()
        time.sleep(2)
    def runTest(self):
        count = 0
        while True:
            try:
                zigbangUrl = "https://www.zigbang.com/"

                confirmAccount = "인증 계정"
                confirmpwAccount = "인증 계정"

                # 0. 직방 웹페이지 접속

                self.driver.get(zigbangUrl)
                time.sleep(1)

                self.driver.add_cookie({'name': 'cookie_sms_app_down', 'value': 'true'})
                # 지도 앱 다운로드 팝업 쿠키 True 값 고정

                self.driver.maximize_window()

                # 1. 오피스텔 접속

                element_to_hover_over = self.wait.until(EC.visibility_of_all_elements_located((By.CLASS_NAME, "has_d2")))[0]
                hover = ActionChains(self.driver).move_to_element(element_to_hover_over)
                hover.perform()

                self.wait.until(EC.visibility_of_element_located((By.LINK_TEXT, "오피스텔(도시형생활주택)"))).click()
                time.sleep(1)

                # 2. 오피스텔 지도 화면 > 지하철역 검색

                self.wait.until(EC.visibility_of_element_located((By.ID, "officetel-textfield"))).send_keys(u"강남역")
                time.sleep(1)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-search"))).click()
                time.sleep(1)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-delete"))).click()
                time.sleep(1)

                # 3. 오피스텔 지도 화면 > 오피스텔 검색

                self.wait.until(EC.visibility_of_element_located((By.ID, "officetel-textfield"))).send_keys(u"테스트할 오피스텔 명")
                time.sleep(1)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-search"))).click()
                time.sleep(3)

                buildingName = self.wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".list-title > h3")))[0].text[0:12]
                if not u"테스트할 오피스텔 명" == buildingName:
                    raise Exception(u"오피스텔이름이 일치하지 않습니다.", buildingName)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-delete"))).click()
                time.sleep(1)

                # 4. 원룸 지도 화면 > 지역 검색

                self.wait.until(EC.visibility_of_element_located((By.ID, "officetel-textfield"))).send_keys(u"서울시 강남구 역삼동")
                time.sleep(1)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-search"))).click()
                time.sleep(3)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-delete"))).click()
                time.sleep(1)

                # 5. 매물 상세 진입

                listItem = self.wait.until(EC.visibility_of_all_elements_located((By.CLASS_NAME, "list-item")))
                listItem[0].click()
                self.moveTab(1)
                time.sleep(1)

                # 6. 사진 개수 유효성 검사

                imgItem = self.driver.find_elements_by_css_selector('.item-pager > a')
                # imgItem = self.wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, '.item-pager > a')))

                if not len(imgItem) >= 5:
                    raise Exception(u"등록된 사진 개수가 5개 미만입니다.", len(imgItem))

                time.sleep(1)

                # 7. 인증 로그인 및 찜 하기

                self.wait.until(EC.visibility_of_all_elements_located((By.CLASS_NAME, "icon-question2")))[0].click()
                time.sleep(1)

                self.wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "btn-close"))).click()

                self.wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button[class='btn-zzim off']"))).click()

                self.wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "link1"))).click()

                self.wait.until(EC.visibility_of_element_located((By.NAME, "username"))).send_keys(confirmAccount)

                self.wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".mb-20 > button"))).click()
                time.sleep(3)

                self.wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[type='password']"))).send_keys(confirmpwAccount)

                self.wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "button[type='submit']")))[0].click()
                time.sleep(3)

                self.wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button[class='btn-zzim off']"))).click()
                time.sleep(3)

                self.wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "button[type='submit']")))[0].click()
                time.sleep(1)

                self.driver.close()
                self.moveTab(0)

                # 8. 테스트 매물 상세 진입

                # self.driver.execute_script('''window.open("https://www.zigbang.com/items1/10167786","_blank");''')
                #
                # self.moveTab(1)

                self.wait.until(EC.visibility_of_element_located((By.ID, "officetel-textfield"))).send_keys(u"테스트할 오피스텔 명")
                time.sleep(1)

                self.wait.until(EC.visibility_of_element_located((By.ID, "btn-officetel-search"))).click()
                time.sleep(3)

                self.wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "list-close"))).click()
                time.sleep(1)

                listItem = self.wait.until(EC.visibility_of_all_elements_located((By.CLASS_NAME, "list-item ")))
                listItem[0].click()
                self.moveTab(1)

                # 9. 연락처 보기 / 문자 보내기

                self.wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "call_btn"))).click()

                dt = datetime.datetime.now().hour

                self.wait.until(EC.visibility_of_element_located((By.ID, "phone"))).send_keys("테스트 휴대폰 번호")

                self.wait.until(EC.visibility_of_element_located((By.ID, "comment"))).send_keys(u"테스트 문자 내용")

                if (dt > 22 or dt < 8):

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry4"))).click()

                    self.wait.until(EC.alert_is_present()).accept()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "check_agree"))).click()
                    time.sleep(3)

                    self.driver.find_elements_by_css_selector(".layer-btn > button")[1].click()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry4"))).click()

                    self.wait.until(EC.alert_is_present()).accept()
                    time.sleep(1)

                else:

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry"))).click()

                    self.wait.until(EC.alert_is_present()).accept()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "check_agree"))).click()
                    time.sleep(3)

                    self.driver.find_elements_by_css_selector(".layer-btn > button")[1].click()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry"))).click()

                    self.wait.until(EC.alert_is_present()).accept()
                    time.sleep(1)

                # 10. 중개사무소 정보 보기 / 매물 개수 체크 / 이것 저것 버튼 클릭

                self.wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "info_btn"))).click()
                self.moveTab(2)

                agentzzimList = self.wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".list-item")))

                if not len(agentzzimList) == 4:
                    raise Exception(u"안심중개사 즐겨찾기 매물 개수가 상이합니다.", len(agentzzimList))

                self.driver.find_elements_by_class_name("list-item")[0].click()
                self.moveTab(3)
                self.driver.close()
                self.moveTab(2)
                self.driver.close()
                self.moveTab(1)

                # 11. 추천 매물 더보기

                self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

                self.wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "view_agent_reco"))).click()
                self.moveTab(2)
                self.driver.close()
                self.moveTab(1)

                self.driver.execute_script("window.scrollTo(0, 0);")

                # 12. 간편하게 문의 요청하기

                dt2 = datetime.datetime.now().hour

                if (dt2 > 22 or dt2 < 8):

                    self.wait.until(EC.visibility_of_element_located((By.ID, "phone3"))).send_keys("테스트 휴대폰 번호")

                    self.wait.until(EC.visibility_of_element_located((By.ID, "comment3"))).send_keys(u"테스트 문자 내용")

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry3"))).click()

                    self.wait.until(EC.alert_is_present()).accept()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "check_agree3"))).click()
                    time.sleep(3)

                    self.driver.find_elements_by_css_selector(".layer-btn > button")[1].click()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry3"))).click()

                    self.wait.until(EC.alert_is_present()).accept()
                    time.sleep(1)

                else:

                    self.wait.until(EC.visibility_of_element_located((By.ID, "phone2"))).send_keys("테스트 휴대폰 번호")

                    self.wait.until(EC.visibility_of_element_located((By.ID, "comment2"))).send_keys(u"테스트 문자 내용")

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry2"))).click()

                    self.wait.until(EC.alert_is_present()).accept()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "check_agree2"))).click()
                    time.sleep(3)

                    self.driver.find_elements_by_css_selector(".layer-btn > button")[1].click()

                    self.wait.until(EC.visibility_of_element_located((By.ID, "btn-inquiry2"))).click()

                    self.wait.until(EC.alert_is_present()).accept()
                    time.sleep(1)

                break

            except Exception:

                if count == 2:
                    raise

                else:
                    traceback.print_exc(file=sys.stdout)
                    print("에러 발생 페이지 URL : ", self.driver.current_url)
                    self.driver.quit()
                    self.setUp()
                    count += 1
Esempio n. 48
0
 def creditcard_payment(browser, req):
     """
     支付页面有两种形式,此为输入信用卡号的形式(无航空指南)
     :param browser:
     :param req:东京到首尔,
     :return:
     """
     WebDriverWait(browser, 50).until(
         EC.visibility_of_element_located((By.ID, 'foreign_credit_card')))
     browser.find_element_by_id(
         "foreign_credit_card").find_element_by_class_name(
             "iradio_minimal-red").click()
     creditInfo = req.creditCardInfo
     cardNumber = creditInfo["cardNumber"]
     cutCardNum = cardNumber.split(" ")
     name = creditInfo["name"]
     firstName = name.split(" ")[0]
     lastName = name.split(" ")[1]
     browser.find_element_by_id('jpy_card_1').send_keys(cutCardNum[0])
     browser.find_element_by_id("jpy_card_2").send_keys(cutCardNum[1])
     browser.find_element_by_id("jpy_card_3").send_keys(cutCardNum[2])
     browser.find_element_by_id("jpy_card_4").send_keys(cutCardNum[3])
     card_expire = creditInfo["validityPeriod"]
     card_expire_Num = card_expire.split("/")
     browser.find_element_by_id("jpy_mm").send_keys(card_expire_Num[0])
     browser.find_element_by_id("jpy_yy").send_keys(card_expire_Num[1])
     browser.find_element_by_id("jpy_cvc").send_keys(creditInfo["cvv"])
     # 下滑到底部
     js = "var q=document.documentElement.scrollTop=100000"
     browser.execute_script(js)
     ch = browser.current_window_handle
     browser.find_element_by_id("PNWBA00014").find_element_by_class_name(
         "icheckbox_minimal-red").click()
     browser.find_element_by_id("PNWBA00014").find_element_by_class_name(
         "btn-color04").click()
     t = booker_config.getint('eastarjet', 'time')
     time.sleep(t)
     # 所有的window handles
     wh = browser.window_handles
     # 在所有窗口中查找弹出窗口
     browser.switch_to.window(wh[-1])
     time.sleep(t)
     cardNumber = creditInfo["cardNumber"]
     cutCardNum = cardNumber.split(" ")
     browser.find_element_by_id("viewcardno1").send_keys(cutCardNum[0])
     browser.find_element_by_id("viewcardno2").send_keys(cutCardNum[1])
     browser.find_element_by_id("viewcardno3").send_keys(cutCardNum[2])
     browser.find_element_by_id("viewcardno4").send_keys(cutCardNum[3])
     cvv = creditInfo["cvv"]
     browser.find_element_by_name("cvv").send_keys(cvv)
     validityPeriod = creditInfo["validityPeriod"]
     date = validityPeriod.split("/")
     # 下拉按钮:月份,年份
     browser.find_element_by_id("monthtd").click()
     a = browser.find_element_by_id("monthtd").find_element_by_class_name(
         "sbOptions")
     time.sleep(t)
     a.find_elements_by_tag_name("li")[int(
         date[0])].find_element_by_tag_name("a").click()
     browser.find_element_by_id("yeartd").click()
     time.sleep(t)
     YY = browser.find_element_by_id("yeartd").find_element_by_class_name(
         "sbOptions").find_elements_by_tag_name("li")
     for item in YY:
         YY_value = item.find_element_by_tag_name("a").text
         if date[1] in YY_value:
             item.click()
             break
     # 名字
     browser.find_element_by_id("fname").send_keys(firstName)
     browser.find_element_by_id("lname").send_keys(lastName)
     browser.find_element_by_class_name("footer_btn").click()
     time.sleep(2)
     browser.find_element_by_id("JPY").click()
     browser.find_element_by_name("agree").click()
     browser.find_element_by_class_name("btn-primary").click()