class Public_Edit_User:

    def __init__(self, driver):

        self.chrome = driver
        self.driver_func = Driver_Action( driver )
        self.admin_xpath_list_func = Admin_Menu_Path()
        self.basic_func = Basic()
        # 管理画面のメニューのパスを返す
        self.admin_xpath_lists_xpath = self.admin_xpath_list_func.get_admin_menu_xpath()

        # 管理画面メニュー内の新規追加や編集などのパーツのパスを返す。
        self.admin_list_parts_xpath = self.admin_xpath_list_func.get_admin_menu_list_parts_xpath()

        # 管理画面内の項目に関するパス(作成した固定ページリストとか)
        self.admin_parts_xpath = self.admin_xpath_list_func.get_admin_parts()

        #ユーザー画面内の項目に関するパス
        self.public_parts_xpath = self.admin_xpath_list_func.get_public_parts()

        self.base_dir = self.basic_func.get_base_dir_path()

        self.my_page_url = self.basic_func.get_my_page_url()

    def go_to_my_page( self ):
        self.chrome.get( self.my_page_url )

    def go_to_edit_page( self ):
        edit_btn_xpath = self.public_parts_xpath['edit_btn_xpath']
        edit_btn_elem = self.driver_func.get_element_by_xpath( edit_btn_xpath )
        self.driver_func.click_item( edit_btn_elem )

    def edit_user_info( self ):

        first_name_elem = self.driver_func.get_element_by_name( 'first_name' )
        last_name_elem = self.driver_func.get_element_by_name( 'last_name' )
        user_email_elem = self.driver_func.get_element_by_name( 'user_email' )
        submit_elem = self.driver_func.get_element_by_id( 'submit' )
        
        self.driver_func.clear_item_info( first_name_elem )
        self.driver_func.put_item_info( first_name_elem, 'edit_first_name_test' )

        self.driver_func.clear_item_info( last_name_elem )
        self.driver_func.put_item_info( last_name_elem, 'edit_last_name_test' )

        self.driver_func.click_item( submit_elem )
Esempio n. 2
0
class Public_Calendar:
    def __init__(self, driver):

        self.chrome = driver
        self.driver_func = Driver_Action(driver)
        self.admin_xpath_list_func = Admin_Menu_Path()
        self.basic_func = Basic()
        # 管理画面のメニューのパスを返す
        self.admin_xpath_lists_xpath = self.admin_xpath_list_func.get_admin_menu_xpath(
        )

        # 管理画面メニュー内の新規追加や編集などのパーツのパスを返す。
        self.admin_list_parts_xpath = self.admin_xpath_list_func.get_admin_menu_list_parts_xpath(
        )

        # 管理画面内の項目に関するパス(作成した固定ページリストとか)
        self.admin_parts_xpath = self.admin_xpath_list_func.get_admin_parts()

        #ユーザー画面内の項目に関するパス
        self.public_parts_xpath = self.admin_xpath_list_func.get_public_parts()

        self.base_dir = self.basic_func.get_base_dir_path()

        self.calendar_page_url = self.basic_func.get_calendar_page_url()

    def go_to_calendar_page(self):

        self.driver_func.move_to_page_by_link(self.chrome,
                                              self.calendar_page_url)

    def click_calendar(self, target_calendar_name):
        calendar_cell_xpath = self.public_parts_xpath[
            'calendar_cell_list_xpath']
        calendar_cells = self.driver_func.get_elements_by_xpath(
            calendar_cell_xpath)

        calendar_cell_elem = self.basic_func.get_target_element(
            calendar_cells, target_calendar_name)
        self.driver_func.click_item(calendar_cell_elem)

    def go_to_calendar_register_page(self):
        calendar_register_xpath = self.public_parts_xpath[
            'calendar_cell_register_xpath']
        calendar_register_elem = self.driver_func.get_element_by_xpath(
            calendar_register_xpath)
        self.driver_func.click_item(calendar_register_elem)

    def put_calendar_register_info(self):

        date_time1_elem = self.driver_func.get_element_by_name('date_time1')
        date_time2_elem = self.driver_func.get_element_by_name('date_time2')
        comment_elem = self.driver_func.get_element_by_name('comment')
        submit_btn_elem = self.driver_func.get_element_by_id('submit')

        self.driver_func.put_item_info(date_time1_elem, '13:00')
        self.driver_func.put_item_info(date_time2_elem, '16:00')
        self.driver_func.put_item_info(comment_elem, 'かれんだーてすと')

        self.driver_func.click_item(submit_btn_elem)

    def go_to_calendar_edit_page(self):
        calendar_edit_xpath = self.public_parts_xpath[
            'calendar_cell_edit_xpath']
        calendar_edit_elem = self.driver_func.get_element_by_xpath(
            calendar_edit_xpath)
        self.driver_func.click_item(calendar_edit_elem)

    def put_calendar_edit_info(self):

        date_time1_elem = self.driver_func.get_element_by_name('date_time1')
        date_time2_elem = self.driver_func.get_element_by_name('date_time2')
        comment_elem = self.driver_func.get_element_by_name('comment')
        submit_btn_elem = self.driver_func.get_element_by_id('submit')

        self.driver_func.clear_item_info(date_time1_elem)
        self.driver_func.put_item_info(date_time1_elem, '13:00')

        self.driver_func.clear_item_info(date_time2_elem)
        self.driver_func.put_item_info(date_time2_elem, '16:00')

        self.driver_func.clear_item_info(comment_elem)
        self.driver_func.put_item_info(comment_elem, 'かれんだーてすと')

        self.driver_func.click_item(submit_btn_elem)
Esempio n. 3
0
class Test_User_Payment_Register:

    def __init__(self, driver):
        self.chrome = driver
        self.driver_func = Driver_Action( driver )

    #GuildPressのページで、PayPal決済ボタンをクリックした後にページが表示されているかチェックする関数
    def is_first_paypal_page_loaded( self ):

        try:
            self.driver_func.stop(10)
            payment_btn_xpath = '//button[@type="submit"]'
            target_click = '//a[text()="ここをクリックしてください"]'
            payment_btn = self.driver_func.get_element_by_xpath(payment_btn_xpath)
        except NoSuchElementException:
            print('no page')
            return self.is_first_paypal_page_loaded()
        else:
            print('page')
            return True

    def is_next_paypal_page_loaded( self ):

        try:
            self.driver_func.stop(10)

            login_email_elem = self.driver_func.get_element_by_name( 'login_email' )
            self.driver_func.clear_item_info( login_email_elem )
            self.driver_func.put_item_info( login_email_elem, 'paypalのメールアドレスを記載' )
        except NoSuchElementException:
            print('no is_next_paypal_page_loaded')
            return self.is_next_paypal_page_loaded()
        else:
            print('is_next_paypal_page_loaded')

            return True

    def is_third_paypal_page_loaded(self):

        try:
            self.driver_func.stop(10)
            login_password_elem = self.driver_func.get_element_by_name( 'login_password' )
            self.driver_func.clear_item_info( login_password_elem )
            self.driver_func.put_item_info( login_password_elem, 'passwordを記載' )

            btnLogin_elem = self.driver_func.get_element_by_name( 'btnLogin' )

        except NoSuchElementException:
            print('no is_third_paypal_page_loaded')
            return self.is_third_paypal_page_loaded()
        else:
            print('is_third_paypal_page_loaded')
            return True


    def is_last_paypal_page_loaded(self):

        try:
            self.driver_func.stop(10)
            confirmButtonTop_elem = self.driver_func.get_element_by_id( 'confirmButtonTop' )

        except NoSuchElementException:
            print('no is_last_paypal_page_loaded')
            return self.is_last_paypal_page_loaded()
        else:
            print('is_last_paypal_page_loaded')
            return True

    def click_new_register_page_pay_pal_btn( self ):

        pay_pal_btn_xpath = '//button[@id="paypal_btn"]'
        pay_pal_btn = self.driver_func.get_element_by_xpath(pay_pal_btn_xpath)
        pay_pal_btn.click()

        is_result = self.is_first_paypal_page_loaded()
        if( is_result == True ):
            self.driver_func.stop(15)
            payment_btn_xpath = '//button[@type="submit"]'
            payment_btn = self.driver_func.get_element_by_xpath(payment_btn_xpath)
            self.driver_func.click_item( payment_btn )

        is_thrid_result = self.is_new_paypal_page_loaded()
        if( is_thrid_result == True ):
            self.driver_func.stop(15)
            btnLogin_elem = self.driver_func.get_element_by_name( 'btnLogin' )
            self.driver_func.click_item( btnLogin_elem )

        is_last_result = self.is_last_paypal_page_loaded()
        if( is_last_result == True ):
            self.driver_func.get_element_by_id( 'confirmButtonTop' ).click()

        self.driver_func.stop(15)

    def is_new_paypal_page_loaded( self ):

        try:
            self.driver_func.stop(10)

            login_email_elem = self.driver_func.get_element_by_name( 'login_email' )
            self.driver_func.clear_item_info( login_email_elem )
            self.driver_func.put_item_info( login_email_elem, 'paypalのメールアドレスを記載' )

            login_password_elem = self.driver_func.get_element_by_name( 'login_password' )
            self.driver_func.clear_item_info( login_password_elem )
            self.driver_func.put_item_info( login_password_elem, 'passwordを記載' )

        except NoSuchElementException:
            print('no is_next_paypal_page_loaded')
            return self.is_next_paypal_page_loaded()
        else:
            print('is_next_paypal_page_loaded')

            return True

    def click_register_page_pay_pal_btn( self ):

        pay_pal_btn_xpath = '//button[@id="paypal_btn"]'
        pay_pal_btn = self.driver_func.get_element_by_xpath(pay_pal_btn_xpath)
        pay_pal_btn.click()

        is_result = self.is_first_paypal_page_loaded()
        if( is_result == True ):
            self.driver_func.stop(15)
            payment_btn_xpath = '//button[@type="submit"]'
            payment_btn = self.driver_func.get_element_by_xpath(payment_btn_xpath)
            self.driver_func.click_item( payment_btn )

        is_next_result = self.is_next_paypal_page_loaded()
        if( is_next_result == True ):
            self.driver_func.stop(15)
            next_payment_btn_xpath = '//button[@type="submit"][text()="次へ"]'
            next_payment_btn = self.driver_func.get_element_by_xpath(next_payment_btn_xpath)
            self.driver_func.click_item( next_payment_btn )

        self.driver_func.stop(15)
        result = self.check_paypal_login_email()

        if( result == True ):
            is_next_result = self.is_next_paypal_page_loaded()
            if( is_next_result == True ):
                next_payment_btn_xpath = '//button[@type="submit"][text()="次へ"]'
                next_payment_btn = self.driver_func.get_element_by_xpath(next_payment_btn_xpath)
                self.driver_func.click_item( next_payment_btn )


        is_thrid_result = self.is_third_paypal_page_loaded()
        if( is_thrid_result == True ):
            self.driver_func.stop(15)
            btnLogin_elem = self.driver_func.get_element_by_name( 'btnLogin' )
            self.driver_func.click_item( btnLogin_elem )

        is_last_result = self.is_last_paypal_page_loaded()
        if( is_last_result == True ):
            self.driver_func.get_element_by_id( 'confirmButtonTop' ).click()

        self.driver_func.stop(15)

    def check_paypal_login_email(self):
        try:
            email_input = self.driver_func.get_element_by_name('login_email')
        except NoSuchElementException:
            return False

        if( email_input.is_displayed() == True ):
            return True
        else :
            return False
Esempio n. 4
0
class Lesson_Over_View_Posts:
    def __init__(self, driver):
        self.chrome = driver
        self.driver_func = Driver_Action(driver)
        self.admin_xpath_list_func = Admin_Menu_Path()
        self.basic_func = Basic()
        self.admin_xpath_lists_xpath = self.admin_xpath_list_func.get_admin_menu_xpath(
        )
        self.admin_list_parts_xpath = self.admin_xpath_list_func.get_admin_menu_list_parts_xpath(
        )
        self.admin_parts_xpath = self.admin_xpath_list_func.get_admin_parts()

    def add_lesson_over_view_page(self):
        #ポストのタイトル、テキストのディレクトリ、カテゴリー名、アイキャッチ画像
        base_dir = self.basic_func.get_base_dir_path()
        lesson_overview = {
            'first_lesson_over_view': {
                'post_title':
                '英語初級講座',
                'category_name':
                '英語初級講座',
                'text_dir':
                base_dir + '/assets/texts/beginner/english-beginner.txt',
                'img_dir':
                base_dir + '/assets/img/beginner/english-beginner-overview.png'
            },
            'second_lesson_over_view': {
                'post_title':
                '英語中級講座',
                'category_name':
                '英語中級講座',
                'text_dir':
                base_dir + '/assets/texts/normal/english-normal.txt',
                'img_dir':
                base_dir + '/assets/img/normal/english-normal-overview.png'
            },
            'third_lesson_over_view': {
                'post_title':
                '英語上級講座',
                'category_name':
                '英語上級講座',
                'text_dir':
                base_dir + '/assets/texts/advanced/english-advanced.txt',
                'img_dir':
                base_dir + '/assets/img/advanced/english-advanced-overview.png'
            }
        }

        for list_loop_name, lesson_overview_lists in lesson_overview.items():
            self.create_new_lesson_over_view_page(lesson_overview_lists)

    def create_new_lesson_over_view_page(self, lesson_overview_lists):

        #要素を取得するためのXpathのリストを準備
        lesson_list_path = self.admin_xpath_lists_xpath[
            'admin_guild_press_lesson_over_view_list_page_path']
        add_new_lesson_list_path = self.admin_list_parts_xpath['add_new_page']

        #Xpathで、各要素を取得
        publish_post_btn = self.admin_parts_xpath['publish_post_btn']
        add_new_element = self.driver_func.get_element_by_xpath(
            add_new_lesson_list_path)

        #新規追加をクリックして、移動。
        self.driver_func.click_item(add_new_element)

        self.put_contents(lesson_overview_lists)

        self.upload_img(lesson_overview_lists)

        self.upload_thumbnail(lesson_overview_lists)

        #公開ボタンを押す。
        # publish_post_btn_element = self.driver_func.get_element_by_xpath( publish_post_btn )
        # self.driver_func.click_item( publish_post_btn_element )
        self.driver_func.click_publish_btn()

        self.driver_func.stop(0.5)

        #一度他のページへ移動
        self.driver_func.move_admin_page(
            self.admin_xpath_lists_xpath['admin_main_setting_path'],
            self.admin_xpath_lists_xpath['admin_sub_setting_path'])

        self.driver_func.move_admin_page(
            self.admin_xpath_lists_xpath[
                'admin_guild_press_lesson_over_view_page_path'],
            self.admin_xpath_lists_xpath[
                'admin_guild_press_lesson_over_view_list_page_path'])

    def put_contents(self, lesson_overview_lists):
        #各要素を取得して、入力していく。
        post_title_element = self.driver_func.get_element_by_name('post_title')

        self.driver_func.put_item_info(post_title_element,
                                       lesson_overview_lists['post_title'])

        content_html = self.driver_func.get_element_by_id('content-html')
        self.driver_func.click_item(content_html)

        content_box_element = self.driver_func.get_element_by_name('content')
        content_text = self.basic_func.get_file_text(
            lesson_overview_lists['text_dir'])
        self.driver_func.put_item_info(content_box_element, content_text)

        category_box_element = self.driver_func.get_element_by_id(
            'guild_lesson_category-add-toggle')
        self.driver_func.click_item(category_box_element)

        category_input_element = self.driver_func.get_element_by_name(
            'newguild_lesson_category')
        self.driver_func.put_item_info(category_input_element,
                                       lesson_overview_lists['category_name'])

        category_submit_element = self.driver_func.get_element_by_id(
            'guild_lesson_category-add-submit')
        self.driver_func.click_item(category_submit_element)

    def upload_img(self, lesson_overview_lists):
        media_submit_btn = self.admin_parts_xpath['media_submit_btn']
        media_input_file = self.admin_parts_xpath['media_input_file']
        self.driver_func.stop(0.5)

        #メディアを入れるためにボタンをクリックする。
        media_btn_html = self.driver_func.get_element_by_id(
            'insert-media-button')
        self.driver_func.click_item(media_btn_html)

        #画像をアップロード
        img_btn_element = self.driver_func.get_element_by_xpath(
            media_input_file)
        self.driver_func.put_item_info(img_btn_element,
                                       lesson_overview_lists['img_dir'])

        #アップロードが終了して、完了ボタンが押せるかチェック。
        self.is_click_media_submit_btn()

    def upload_thumbnail(self, lesson_overview_lists):
        media_input_file = self.admin_parts_xpath['media_input_file']
        media_add_eye_catch_btn = self.admin_parts_xpath[
            'media_add_eye_catch_btn']
        media_eye_catch_submit_btn = self.admin_parts_xpath[
            'media_eye_catch_submit_btn']

        #サムネイルを入れるためにボタンをクリックする。
        media_btn_html = self.driver_func.get_element_by_xpath(
            media_add_eye_catch_btn)
        self.driver_func.click_item(media_btn_html)

        #画像をアップロード
        img_btn_element = self.driver_func.get_element_by_xpath(
            media_input_file)
        self.driver_func.put_item_info(img_btn_element,
                                       lesson_overview_lists['img_dir'])

        #アップロードした後しばらく待つ。
        self.is_click_thumbnail_submit_btn()

    def is_click_thumbnail_submit_btn(self):

        media_eye_catch_submit_btn = self.admin_parts_xpath[
            'media_eye_catch_submit_btn']

        self.driver_func.stop(0.5)
        eye_chactch_submit_element = self.driver_func.get_element_by_xpath(
            media_eye_catch_submit_btn)

        if (eye_chactch_submit_element.is_enabled()):
            print('is_click_thumbnail_submit_btn')
            self.driver_func.click_item(eye_chactch_submit_element)

        else:
            print('no is_click_thumbnail_submit_btn')
            self.is_click_thumbnail_submit_btn()

    def is_click_media_submit_btn(self):

        media_submit_btn = self.admin_parts_xpath['media_submit_btn']

        self.driver_func.stop(0.5)
        img_submit_element = self.driver_func.get_element_by_xpath(
            media_submit_btn)

        if (img_submit_element.is_enabled()):
            self.driver_func.click_item(img_submit_element)

        else:
            self.is_click_media_submit_btn()
Esempio n. 5
0
class Lesson_Detail_Posts:

    def __init__(self, driver):
        self.chrome = driver
        self.driver_func = Driver_Action( driver )
        self.admin_xpath_list_func = Admin_Menu_Path()
        self.basic_func = Basic()
        self.admin_xpath_lists_xpath = self.admin_xpath_list_func.get_admin_menu_xpath()
        self.admin_list_parts_xpath = self.admin_xpath_list_func.get_admin_menu_list_parts_xpath()
        self.admin_parts_xpath = self.admin_xpath_list_func.get_admin_parts()

    def add_lesson_detail_page(self):
        #ポストのタイトル、テキストのディレクトリ、カテゴリー名、アイキャッチ画像
        base_dir = self.basic_func.get_base_dir_path()
        lesson_details = {
            'beginner_lesson_details' : {
                'first_lesson_details' : {
                    'post_title' : '英語文法(初級講座)',
                    'category_name' : '英語初級講座',
                    'text_dir' : base_dir+'/assets/texts/beginner/english-beginner-grammer.txt',
                    'img_dir' : base_dir+'/assets/img/beginner/english-beginner-grammer.png'
                },
                'second_lesson_details' : {
                    'post_title' : '英語リスニング(初級講座)',
                    'category_name' : '英語初級講座',
                    'text_dir' : base_dir+'/assets/texts/beginner/english-beginner-listening.txt',
                    'img_dir' : base_dir+'/assets/img/beginner/english-beginner-listening.png'
                },
                'third_lesson_details' : {
                    'post_title' : '英語リーディング(初級講座)',
                    'category_name' : '英語初級講座',
                    'text_dir' : base_dir+'/assets/texts/beginner/english-beginner-reading.txt',
                    'img_dir' : base_dir+'/assets/img/beginner/english-beginner-reading.png'
                },
                'fourth_lesson_details' : {
                    'post_title' : '英語スピーキング(初級講座)',
                    'category_name' : '英語初級講座',
                    'text_dir' : base_dir+'/assets/texts/beginner/english-beginner-speaking.txt',
                    'img_dir' : base_dir+'/assets/img/beginner/english-beginner-speaking.png'
                },
                'fifth_lesson_details' : {
                    'post_title' : '英語単語(初級講座)',
                    'category_name' : '英語初級講座',
                    'text_dir' : base_dir+'/assets/texts/beginner/english-beginner-words.txt',
                    'img_dir' : base_dir+'/assets/img/beginner/english-beginner-words.png'
                }
            },
            'normal_lesson_details' : {
                'first_lesson_details' : {
                    'post_title' : '英語文法(中級講座)',
                    'category_name' : '英語中級講座',
                    'text_dir' : base_dir+'/assets/texts/normal/english-normal-grammer.txt',
                    'img_dir' : base_dir+'/assets/img/normal/english-normal-grammer.png'
                },
                'second_lesson_details' : {
                    'post_title' : '英語リスニング(中級講座)',
                    'category_name' : '英語中級講座',
                    'text_dir' : base_dir+'/assets/texts/normal/english-normal-listening.txt',
                    'img_dir' : base_dir+'/assets/img/normal/english-normal-listening.png'
                },
                'third_lesson_details' : {
                    'post_title' : '英語リーディング(中級講座)',
                    'category_name' : '英語中級講座',
                    'text_dir' : base_dir+'/assets/texts/normal/english-normal-reading.txt',
                    'img_dir' : base_dir+'/assets/img/normal/english-normal-reading.png'
                },
                'fourth_lesson_details' : {
                    'post_title' : '英語スピーキング(中級講座)',
                    'category_name' : '英語中級講座',
                    'text_dir' : base_dir+'/assets/texts/normal/english-normal-speaking.txt',
                    'img_dir' : base_dir+'/assets/img/normal/english-normal-speaking.png'
                },
                'fifth_lesson_details' : {
                    'post_title' : '英語単語(中級講座)',
                    'category_name' : '英語中級講座',
                    'text_dir' : base_dir+'/assets/texts/normal/english-normal-words.txt',
                    'img_dir' : base_dir+'/assets/img/normal/english-normal-words.png'
                }
            },
            'advanced_lesson_details' : {
                'first_lesson_details' : {
                    'post_title' : '英語文法(上級講座)',
                    'category_name' : '英語上級講座',
                    'text_dir' : base_dir+'/assets/texts/advanced/english-advanced-grammer.txt',
                    'img_dir' : base_dir+'/assets/img/advanced/english-advanced-grammer.png'
                },
                'second_lesson_details' : {
                    'post_title' : '英語リスニング(上級講座)',
                    'category_name' : '英語上級講座',
                    'text_dir' : base_dir+'/assets/texts/advanced/english-advanced-listening.txt',
                    'img_dir' : base_dir+'/assets/img/advanced/english-advanced-listening.png'
                },
                'third_lesson_details' : {
                    'post_title' : '英語リーディング(上級講座)',
                    'category_name' : '英語上級講座',
                    'text_dir' : base_dir+'/assets/texts/advanced/english-advanced-reading.txt',
                    'img_dir' : base_dir+'/assets/img/advanced/english-advanced-reading.png'
                },
                'fourth_lesson_details' : {
                    'post_title' : '英語スピーキング(上級講座)',
                    'category_name' : '英語上級講座',
                    'text_dir' : base_dir+'/assets/texts/advanced/english-advanced-speaking.txt',
                    'img_dir' : base_dir+'/assets/img/advanced/english-advanced-speaking.png'
                },
                'fifth_lesson_details' : {
                    'post_title' : '英語単語(上級講座)',
                    'category_name' : '英語上級講座',
                    'text_dir' : base_dir+'/assets/texts/advanced/english-advanced-words.txt',
                    'img_dir' : base_dir+'/assets/img/advanced/english-advanced-words.png'
                }
            }
        }

        #for list_loop_name,lesson_details_lists in lesson_overview.items():

        for details_item_name, details_item_value in lesson_details.items():
            for list_name,lesson_details_lists in details_item_value.items():
                self.create_new_lesson_detail_page( lesson_details_lists )

    def create_new_lesson_detail_page( self, lesson_details_lists ):

        #要素を取得するためのXpathのリストを準備
        lesson_list_path = self.admin_xpath_lists_xpath['admin_guild_press_lesson_detail_list_page_path']
        add_new_lesson_list_path = self.admin_list_parts_xpath['add_new_page']

        #Xpathで、各要素を取得
        publish_post_btn = self.admin_parts_xpath['publish_post_btn']

        add_new_element = self.driver_func.get_element_by_xpath( add_new_lesson_list_path )

        #新規追加をクリックして、移動。
        self.driver_func.click_item(add_new_element)

        self.put_contents( lesson_details_lists )

        self.upload_img( lesson_details_lists )

        self.upload_thumbnail( lesson_details_lists )


        #公開ボタンを押す。
        self.driver_func.click_publish_btn()

        self.driver_func.stop(3)

        #一度他のページへ移動
        self.driver_func.move_admin_page( self.admin_xpath_lists_xpath['admin_main_setting_path'], self.admin_xpath_lists_xpath['admin_sub_setting_path'] )

        self.driver_func.move_admin_page( self.admin_xpath_lists_xpath['admin_guild_press_lesson_detail_page_path'], self.admin_xpath_lists_xpath['admin_guild_press_lesson_detail_list_page_path'] )

    def put_contents( self, lesson_details_lists ):
        #各要素を取得して、入力していく。
        post_title_element = self.driver_func.get_element_by_name( 'post_title' )
        self.driver_func.put_item_info( post_title_element, lesson_details_lists['post_title'] )

        #コンテンツを詰める
        content_html = self.driver_func.get_element_by_id('content-html')

        if( not content_html.is_selected() ) :
            self.driver_func.click_item( content_html )

        content_box_element = self.driver_func.get_element_by_name( 'content' )
        content_text = self.basic_func.get_file_text( lesson_details_lists['text_dir'] )
        self.driver_func.put_item_info( content_box_element, content_text )

        self.check_category_box( lesson_details_lists['category_name'] )


    def upload_img( self, lesson_details_lists ):
        media_input_file = self.admin_parts_xpath['media_input_file']

         #メディアを入れるためにボタンをクリックする。
        media_btn_html = self.driver_func.get_element_by_id('insert-media-button')
        self.driver_func.click_item( media_btn_html )

        #画像をアップロード
        img_btn_element = self.driver_func.get_element_by_xpath( media_input_file )
        self.driver_func.put_item_info( img_btn_element, lesson_details_lists['img_dir'] )


        #アップロードした後しばらく待つ。
        self.is_click_media_submit_btn()


    def is_click_media_submit_btn( self ):
        media_submit_btn = self.admin_parts_xpath['media_submit_btn']

        self.driver_func.stop(0.5)
        img_submit_element = self.driver_func.get_element_by_xpath( media_submit_btn )

        if( img_submit_element.is_enabled() ):
            self.driver_func.click_item( img_submit_element )

        else :
            self.is_click_media_submit_btn()


    def upload_thumbnail( self, lesson_details_lists ):
        media_input_file = self.admin_parts_xpath['media_input_file']
        media_add_eye_catch_btn = self.admin_parts_xpath['media_add_eye_catch_btn']
        #サムネイルを入れるためにボタンをクリックする。
        media_btn_html = self.driver_func.get_element_by_xpath( media_add_eye_catch_btn )
        self.driver_func.click_item( media_btn_html )

        #画像をアップロード
        img_btn_element = self.driver_func.get_element_by_xpath( media_input_file )
        self.driver_func.put_item_info( img_btn_element, lesson_details_lists['img_dir'] )

        #アップロードした後しばらく待つ。
        self.is_click_thumbnail_submit_btn()



    def is_click_thumbnail_submit_btn( self ):
        media_eye_catch_submit_btn = self.admin_parts_xpath['media_eye_catch_submit_btn']

        self.driver_func.stop(0.5)
        eye_chactch_submit_element = self.driver_func.get_element_by_xpath( media_eye_catch_submit_btn )

        if( eye_chactch_submit_element.is_enabled() ):
            print('is_click_thumbnail_submit_btn')
            self.driver_func.click_item( eye_chactch_submit_element )

        else :
            print('no is_click_thumbnail_submit_btn')
            self.is_click_thumbnail_submit_btn()





    def check_category_box( self, tareget_text ):

        cat_lists = '//ul[@id="guild_lesson_categorychecklist"]/li'
        cat_lists_check_box = '//ul[@id="guild_lesson_categorychecklist"]/li/label/input'

        category_list_element = self.driver_func.get_elements_by_xpath( cat_lists )
        category_box_element = self.driver_func.get_elements_by_xpath( cat_lists_check_box )

        for element, checkbox in zip( category_list_element, category_box_element ) :
            text = element.text

            if( text == tareget_text and not checkbox.is_selected() ):
                checkbox.click()
Esempio n. 6
0
class Many_Lesson_Detail_Posts:

    def __init__(self, driver):
        self.chrome = driver
        self.driver_func = Driver_Action( driver )
        self.admin_xpath_list_func = Admin_Menu_Path()
        self.lesson_posts_xpath_list_func = Lesson_Posts_Path()
        self.basic_func = Basic()
        self.admin_xpath_lists_xpath = self.admin_xpath_list_func.get_admin_menu_xpath()
        self.admin_list_parts_xpath = self.admin_xpath_list_func.get_admin_menu_list_parts_xpath()
        self.admin_parts_xpath = self.admin_xpath_list_func.get_admin_parts()

    def add_lesson_detail_page(self):
        #ポストのタイトル、テキストのディレクトリ、カテゴリー名、アイキャッチ画像
        base_dir = self.basic_func.get_base_dir_path()

        self.lesson_posts_xpath_list_func.create_many_lesson_posts()
        lesson_details = self.lesson_posts_xpath_list_func.get_many_lesson_posts_path()

        #for list_loop_name,lesson_details_lists in lesson_overview.items():

        for list_name,lesson_details_lists in lesson_details.items():
            self.create_new_lesson_detail_page( lesson_details_lists )

    def create_new_lesson_detail_page( self, lesson_details_lists ):

        #要素を取得するためのXpathのリストを準備
        lesson_list_path = self.admin_xpath_lists_xpath['admin_guild_press_lesson_detail_list_page_path']
        add_new_lesson_list_path = self.admin_list_parts_xpath['add_new_page']

        #Xpathで、各要素を取得
        publish_post_btn = self.admin_parts_xpath['publish_post_btn']

        add_new_element = self.driver_func.get_element_by_xpath( add_new_lesson_list_path )

        #新規追加をクリックして、移動。
        self.driver_func.click_item(add_new_element)

        self.put_contents( lesson_details_lists )

        self.upload_img( lesson_details_lists )

        self.upload_thumbnail( lesson_details_lists )


        #公開ボタンを押す。
        self.driver_func.click_publish_btn()

        self.driver_func.stop(3)

        #一度他のページへ移動
        self.driver_func.move_admin_page( self.admin_xpath_lists_xpath['admin_main_setting_path'], self.admin_xpath_lists_xpath['admin_sub_setting_path'] )

        self.driver_func.move_admin_page( self.admin_xpath_lists_xpath['admin_guild_press_lesson_detail_page_path'], self.admin_xpath_lists_xpath['admin_guild_press_lesson_detail_list_page_path'] )

    def put_contents( self, lesson_details_lists ):
        #各要素を取得して、入力していく。
        post_title_element = self.driver_func.get_element_by_name( 'post_title' )
        self.driver_func.put_item_info( post_title_element, lesson_details_lists['post_title'] )

        #コンテンツを詰める
        content_html = self.driver_func.get_element_by_id('content-html')

        if( not content_html.is_selected() ) :
            self.driver_func.click_item( content_html )

        content_box_element = self.driver_func.get_element_by_name( 'content' )
        content_text = self.basic_func.get_file_text( lesson_details_lists['text_dir'] )
        self.driver_func.put_item_info( content_box_element, content_text )

        self.check_category_box( lesson_details_lists['category_name'] )


    def upload_img( self, lesson_details_lists ):
        media_input_file = self.admin_parts_xpath['media_input_file']

         #メディアを入れるためにボタンをクリックする。
        media_btn_html = self.driver_func.get_element_by_id('insert-media-button')
        self.driver_func.click_item( media_btn_html )

        #画像をアップロード
        img_btn_element = self.driver_func.get_element_by_xpath( media_input_file )
        self.driver_func.put_item_info( img_btn_element, lesson_details_lists['img_dir'] )


        #アップロードした後しばらく待つ。
        self.is_click_media_submit_btn()


    def is_click_media_submit_btn( self ):
        media_submit_btn = self.admin_parts_xpath['media_submit_btn']

        self.driver_func.stop(0.5)
        img_submit_element = self.driver_func.get_element_by_xpath( media_submit_btn )

        if( img_submit_element.is_enabled() ):
            self.driver_func.click_item( img_submit_element )

        else :
            self.is_click_media_submit_btn()


    def upload_thumbnail( self, lesson_details_lists ):
        media_input_file = self.admin_parts_xpath['media_input_file']
        media_add_eye_catch_btn = self.admin_parts_xpath['media_add_eye_catch_btn']
        #サムネイルを入れるためにボタンをクリックする。
        media_btn_html = self.driver_func.get_element_by_xpath( media_add_eye_catch_btn )
        self.driver_func.click_item( media_btn_html )

        #画像をアップロード
        img_btn_element = self.driver_func.get_element_by_xpath( media_input_file )
        self.driver_func.put_item_info( img_btn_element, lesson_details_lists['img_dir'] )

        #アップロードした後しばらく待つ。
        self.is_click_thumbnail_submit_btn()



    def is_click_thumbnail_submit_btn( self ):
        media_eye_catch_submit_btn = self.admin_parts_xpath['media_eye_catch_submit_btn']

        self.driver_func.stop(0.5)
        eye_chactch_submit_element = self.driver_func.get_element_by_xpath( media_eye_catch_submit_btn )

        if( eye_chactch_submit_element.is_enabled() ):
            print('is_click_thumbnail_submit_btn')
            self.driver_func.click_item( eye_chactch_submit_element )

        else :
            print('no is_click_thumbnail_submit_btn')
            self.is_click_thumbnail_submit_btn()





    def check_category_box( self, tareget_text ):

        cat_lists = '//ul[@id="guild_lesson_categorychecklist"]/li'
        cat_lists_check_box = '//ul[@id="guild_lesson_categorychecklist"]/li/label/input'

        category_list_element = self.driver_func.get_elements_by_xpath( cat_lists )
        category_box_element = self.driver_func.get_elements_by_xpath( cat_lists_check_box )

        for element, checkbox in zip( category_list_element, category_box_element ) :
            text = element.text

            if( text == tareget_text and not checkbox.is_selected() ):
                checkbox.click()
class Google_Calendar_Setting:


	def __init__(self, driver):

		self.chrome = driver
		self.driver_func = Driver_Action( driver )
		self.admin_xpath_list_func = Admin_Menu_Path()
		self.basic_func = Basic()
		# 管理画面のメニューのパスを返す
		self.admin_xpath_lists_xpath = self.admin_xpath_list_func.get_admin_menu_xpath()

		# 管理画面メニュー内の新規追加や編集などのパーツのパスを返す。
		self.admin_list_parts_xpath = self.admin_xpath_list_func.get_admin_menu_list_parts_xpath()

		# 管理画面内の項目に関するパス(作成した固定ページリストとか)
		self.admin_parts_xpath = self.admin_xpath_list_func.get_admin_parts()

		self.base_dir = self.basic_func.get_base_dir_path()

		self.google_api_xpath = self.admin_xpath_list_func.get_google_calendar_api_parts()


	def go_to_google_calendar_setting_page( self ):

		guild_press_setting_tab_elements = self.driver_func.get_elements_by_xpath( self.admin_parts_xpath['guild_press_setting_tab_xpath'] )

		self.driver_func.click_item( guild_press_setting_tab_elements[0] )



	#GoogleカレンダーのIDやシークレットを設定する。
	def put_google_calendar_setting_info( self ):


		google_client_id_element = self.driver_func.get_element_by_name( 'guild_press_google_client_id' )
		self.driver_func.clear_item_info( google_client_id_element )
		self.driver_func.put_item_info( google_client_id_element, 'client_id' )

		google_client_secret_element = self.driver_func.get_element_by_name( 'guild_press_google_client_secret' )
		self.driver_func.clear_item_info( google_client_secret_element )
		self.driver_func.put_item_info( google_client_secret_element, 'secret記載' )

		#情報を保存する。
		save_btn_element = self.driver_func.get_element_by_name( 'set' )
		self.driver_func.click_item( save_btn_element )


	#Googleカレンダーの設定ページへ移動して設定する。
	def set_google_calendar_api( self ):

		#calendar_apiを設定するためのボタンをクリック。
		google_auth_btn_element = self.driver_func.get_element_by_id( 'google_auth_btn' )
		self.driver_func.click_item( google_auth_btn_element )

		try:
			WebDriverWait(self.chrome, 3).until(EC.alert_is_present(),
			'Timed out waiting for PA creation ' +
			'confirmation popup to appear.')

			alert = self.chrome.switch_to.alert
			alert.accept()
			print("alert accepted")
		except TimeoutException:
			print("no alert")

		emails = self.driver_func.get_element_by_name( 'identifier' )
		self.driver_func.clear_item_info( emails )
		self.driver_func.put_item_info( emails, 'メールアドレス記載' )

		next_btn_element = self.driver_func.get_element_by_id( 'identifierNext' )
		self.driver_func.click_item( next_btn_element )

		self.driver_func.stop(3)

		password = self.driver_func.get_element_by_name( 'password' )
		self.driver_func.clear_item_info( password )
		self.driver_func.put_item_info( password, 'パスワード記載' )

		next_btn_element = self.driver_func.get_element_by_id( 'passwordNext' )
		self.driver_func.click_item( next_btn_element )

		self.driver_func.stop(5)


		selector = self.driver_func.get_element_by_css_selector( 'div[class="U26fgb O0WRkf oG5Srb C0oVfc kHssdc M9Bg4d"]' )


		ActionChains(self.chrome ).move_to_element(selector).click(selector).perform()

		self.driver_func.stop(5)

		submit_btn_elem = self.driver_func.get_element_by_id( 'submit_approve_access' )
		self.driver_func.click_item( submit_btn_elem )