Python selenium.webdriver.common.by.By 模块,LINK_TEXT 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用selenium.webdriver.common.by.By.LINK_TEXT

项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
        self.teacher.login()
        # go to student scores
        self.teacher.select_course(appearance='college_physics')
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Student Scores').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(), "Student Scores")]')
            )
        ).click()
项目:instagram-followers-scraper    作者:frabonomi    | 项目源码 | 文件源码
def authenticate(self, username, password):
        """Log in to Instagram with the provided credentials."""

        print('\nLogging in…')
        self.driver.get('https://www.instagram.com')

        # Go to log in
        login_link = WebDriverWait(self.driver, 5).until(
            EC.presence_of_element_located((By.LINK_TEXT, 'Log in'))
        )
        login_link.click()

        # Authenticate
        username_input = self.driver.find_element_by_xpath(
            '//input[@placeholder="Username"]'
        )
        password_input = self.driver.find_element_by_xpath(
            '//input[@placeholder="Password"]'
        )

        username_input.send_keys(username)
        password_input.send_keys(password)
        password_input.send_keys(Keys.RETURN)
        time.sleep(1)
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.teacher.login()
        self.teacher.select_course(appearance='physics')
        self.teacher.open_user_menu()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Course Settings and Roster')
            )
        ).click()
        self.teacher.page.wait_for_page_load()
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
        self.teacher.login()
        # go to student scores
        self.teacher.select_course(appearance='college_physics')
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Student Scores').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(), "Student Scores")]')
            )
        ).click()
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def test_student_view_the_assignemnts_for_the_current_week_8271(self):
        """View the assignments for the current week.

        Steps:
        If the user has more than one course, select a Tutor course

        Expected Result:
        The Assignemnts for the current week are displayed
        """
        self.ps.test_updates['name'] = 't1.45.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.45', 't1.45.004', '8271']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.select_course(appearance='physics')
        self.student.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'This Week')
            )
        )

        self.ps.test_updates['passed'] = True

    # Case C8272 - 005 - Student | View the upcoming assignments
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def test_teacher_view_student_scores_using_the_dashboard_button_7979(self):
        """View student scores using the dashboard button.

        Steps:
        If the user has more than one course, click on a Tutor course name
        Click on the 'Student Scores' button

        Expected Result:
        The teacher is presented with the student scores
        """
        self.ps.test_updates['name'] = 't1.13.002' + \
            inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.13', 't1.13.002', '7979']
        self.ps.test_updates['passed'] = False

        # self.teacher.select_course(title='HS Physics')
        self.teacher.find(By.LINK_TEXT, 'Student Scores').click()
        assert('scores' in self.teacher.current_url()), \
            'Not viewing student scores'

        self.ps.test_updates['passed'] = True

    # Case C7980 - 003 - Teacher | View student scores using the user menu link
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def test_teacher_view_performance_forecast_using_dash_button_7981(self):
        """View performance forecast using the dashboard button.

        Steps:
        If the user has more than one course, click on a Tutor course name
        Click on the 'Performance Forecast' button on the dashboard

        Expected Result:
        The teacher is presented with the performance forecast
        """
        self.ps.test_updates['name'] = 't1.13.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.13', 't1.13.004', '7981']
        self.ps.test_updates['passed'] = False

        self.teacher.find(By.LINK_TEXT, 'Performance Forecast').click()
        self.teacher.page.wait_for_page_load()
        assert('guide' in self.teacher.current_url()), \
            'Not viewing the performance forecast'

        self.ps.test_updates['passed'] = True

    # Case C7982 - 005 - Teacher | View performace forecast using
    # the user menu link
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
        self.teacher.login()
        # go to student scores
        self.teacher.select_course(appearance='college_physics')
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Student Scores').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(), "Student Scores")]')
            )
        ).click()
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
        self.teacher.login()
        # go to student scores
        self.teacher.select_course(appearance='college_physics')
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Student Scores').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(), "Student Scores")]')
            )
        ).click()
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def test_teacher_add_external_assignment_using_drop_down_menu_8085(self):
        """Add an external assignment using the Add Assignment menu.

        Steps:
        Click on the Add Assignment drop down menu
        Click on the Add External Assignment option

        Expected Result:
        User taken to Add External Assignment Page
        """
        self.ps.test_updates['name'] = 't1.18.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.18', 't1.18.001', '8085']
        self.ps.test_updates['passed'] = False

        self.assignment.open_assignment_menu(self.teacher.driver)
        self.teacher.find(
            By.LINK_TEXT, 'Add External Assignment').click()
        assert('external/new' in self.teacher.current_url()),\
            'not at Add External Assignment page'

        self.ps.test_updates['passed'] = True

    # Case C8086 - 002 - Teacher | Add an external assignment using the
    # calendar date
项目:BlackCoffee    作者:IMYin    | 项目源码 | 文件源码
def wait_for_pay(driver):
    retry_times = 0
    try:
        # ????
        while wait_for_submit(driver) is False and retry_times < 20:
            time.sleep(0.01)
            retry_times += 1
        # ????
        WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.ID, "saveConsigneeTitleDiv")))
        WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.LINK_TEXT, "?????????"))).click()
        WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.ID, "order-submit"))).click()
        # ??????
        WebDriverWait(driver, 2, 0.1).until(EC.presence_of_element_located((By.LINK_TEXT, "????")))
    except Exception as error:
        print("?????????\n{}".format(error))
        driver.back()
        driver.back()
        return False
    else:
        return True
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """Finds element within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        """Finds a list of elements within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """
        Finds an element by link text.

        :Args:
         - link_text: The text of the element to be found.

        :Usage:
            driver.find_element_by_link_text('Sign In')
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_elements_by_link_text(self, text):
        """
        Finds elements by link text.

        :Args:
         - link_text: The text of the elements to be found.

        :Usage:
            driver.find_elements_by_link_text('Sign In')
        """
        return self.find_elements(by=By.LINK_TEXT, value=text)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:whatsapp-pybot    作者:iren86    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:whatsapp-pybot    作者:iren86    | 项目源码 | 文件源码
def find_elements_by_link_text(self, text):
        return self.find_elements(by=By.LINK_TEXT, value=text)
项目:whatsapp-pybot    作者:iren86    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:whatsapp-pybot    作者:iren86    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """Finds element within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        """Finds a list of elements within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """
        Finds an element by link text.

        :Args:
         - link_text: The text of the element to be found.

        :Usage:
            driver.find_element_by_link_text('Sign In')
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_elements_by_link_text(self, text):
        """
        Finds elements by link text.

        :Args:
         - link_text: The text of the elements to be found.

        :Usage:
            driver.find_elements_by_link_text('Sign In')
        """
        return self.find_elements(by=By.LINK_TEXT, value=text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def test_teacher_add_an_ext_assignment_by_drag_and_drop_146504(self):
        """
        Steps:
        Click on the 'Add Assignment' menu
        Click and Drag 'Add External Assignment' to a chosen due date

        Expected result:
        User is taken to 'Add External Assignment' page, and due date is filled in as date dragged to
        """
        self.ps.test_updates['name'] = 'tutor_external_teacher' \
                                       + inspect.currentframe().f_code.co_name[
                                         4:]
        self.ps.test_updates['tags'] = ['tutor', 'external', 'teacher',
                                        '146504']
        self.ps.test_updates['passed'] = False

        # Test verification
        self.teacher.assign.open_assignment_menu(self.teacher.driver)
        external_tab = self.teacher.find(
            By.LINK_TEXT, 'Add External Assignment'
        )

        due_date = self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//div[contains(@class,"Day--upcoming")]')
            )
        )
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(external_tab)

        actions.drag_and_drop(external_tab, due_date).perform()
        sleep(3)

        assert ('external/new' in self.teacher.current_url()), \
            'not at Add External Assignment page'

        self.ps.test_updates['passed'] = True


    # Case C146505 017 - Teacher | Info Icons
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def test_teacher_info_icons_146505(self):
        """
        Test info icons

        Steps:
        Click on the 'Add Assignment' sidebar menu
        Click on the "Add External Assignment" option

        Click on the info icon at the bottom

        Expected result:
        Displays description of Publish, Cancel, and Save As Draft statuses.
        """
        self.ps.test_updates['name'] = 'tutor_external_teacher' \
                                       + inspect.currentframe().f_code.co_name[
                                         4:]
        self.ps.test_updates['tags'] = ['tutor', 'external', 'teacher',
                                        '146505']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        assignment_name = 'external_017_%d' % (randint(100, 999))
        assignment = Assignment()

        # Open Add External Assignment page
        assignment.open_assignment_menu(self.teacher.driver)
        self.teacher.find(By.LINK_TEXT, 'Add External Assignment').click()
        assert ('external/new' in self.teacher.current_url()), \
            'not at add external assignment screen'

        # Test info icon
        self.teacher.find(
            By.XPATH, '//button[contains(@class, "footer-instructions")]'
        ).click()
        self.teacher.find(By.ID, 'plan-footer-popover')

        self.ps.test_updates['passed'] = True


    # Case C146506 018 - Teacher | Get assignment links and review metrics
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def test_teacher_add_an_event_by_drag_and_drop_162187(self):
        self.ps.test_updates['name'] = 'tutor_event_teacher' \
                                       + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['tutor', 'event', 'teacher',
                                        '162187']
        self.ps.test_updates['passed'] = False

        # Test verification
        self.teacher.assign.open_assignment_menu(self.teacher.driver)
        event_tab = self.teacher.find(
            By.LINK_TEXT, 'Add Event'
        )

        due_date = self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//div[contains(@class,"Day--upcoming")]')
            )
        )
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(event_tab)

        actions.drag_and_drop(event_tab, due_date).perform()
        sleep(3)

        assert ('event/new' in self.teacher.current_url()), \
            'not at Add Event page'

        self.ps.test_updates['passed'] = True


    # Case C162188 017 Teacher| Get assignment link test info icons
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
        self.wait = WebDriverWait(self.student.driver, Assignment.WAIT_TIME)


        self.teacher.login()

        # go to student scores
        self.teacher.select_course(appearance='biology')
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Student Scores').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(), "Student Scores")]')
            )
        ).click()
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def goto_menu_item(self, item):
        """Go to a specific user menu item."""
        print('Enter: goto_menu_item')
        if 'courses' in self.driver.current_url:
            self.open_user_menu()
            self.wait.until(
                expect.element_to_be_clickable((By.LINK_TEXT, item))
            ).click()
            self.page.wait_for_page_load()
        print('Exit: goto_menu_item')
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def work_assignment(self):
        """Work an assignment."""
        if '/courses/' not in self.current_url():
            self.find(By.XPATH, '//a[contains(@class,"na")]')
        self.wait.until(
            expect.element_to_be_clickable((By.LINK_TEXT, 'All Past Work'))
        )
        raise NotImplementedError(inspect.currentframe().f_code.co_name)
项目:TestRewrite    作者:osqa-interns    | 项目源码 | 文件源码
def goto_past_work(self):
        """View work for previous weeks."""
        self.goto_dashboard()
        self.wait.until(
            expect.element_to_be_clickable((By.LINK_TEXT, 'All Past Work'))
        ).click()
        self.page.wait_for_page_load()
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """Finds element within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        """Finds a list of elements within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """
        Finds an element by link text.

        :Args:
         - link_text: The text of the element to be found.

        :Usage:
            driver.find_element_by_link_text('Sign In')
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_elements_by_link_text(self, text):
        """
        Finds elements by link text.

        :Args:
         - link_text: The text of the elements to be found.

        :Usage:
            driver.find_elements_by_link_text('Sign In')
        """
        return self.find_elements(by=By.LINK_TEXT, value=text)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """Finds element within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        """Finds a list of elements within this element's children by visible link text.

        :Args:
            - link_text - Link text string to search for.
        """
        return self.find_elements(by=By.LINK_TEXT, value=link_text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        """
        Finds an element by link text.

        :Args:
         - link_text: The text of the element to be found.

        :Usage:
            driver.find_element_by_link_text('Sign In')
        """
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_elements_by_link_text(self, text):
        """
        Finds elements by link text.

        :Args:
         - link_text: The text of the elements to be found.

        :Usage:
            driver.find_elements_by_link_text('Sign In')
        """
        return self.find_elements(by=By.LINK_TEXT, value=text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_element_by_link_text(self, link_text):
        return self.find_element(by=By.LINK_TEXT, value=link_text)
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
def find_elements_by_link_text(self, link_text):
        return self.find_elements(by=By.LINK_TEXT, value=link_text)