我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用selenium.webdriver.common.by.By.PARTIAL_LINK_TEXT。
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() self.teacher.select_course(appearance='biology') self.teacher.find(By.PARTIAL_LINK_TEXT, 'Performance Forecast').click()
def find_element_by_partial_link_text(self, link_text): """Finds element within this element's children by partially visible link text. :Args: - link_text - Link text string to search for. """ return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text)
def find_elements_by_partial_link_text(self, link_text): """Finds a list of elements within this element's children by link text. :Args: - link_text - Link text string to search for. """ return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text)
def find_element_by_partial_link_text(self, link_text): """ Finds an element by a partial match of its link text. :Args: - link_text: The text of the element to partially match on. :Usage: driver.find_element_by_partial_link_text('Sign') """ return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text)
def find_elements_by_partial_link_text(self, link_text): """ Finds elements by a partial match of their link text. :Args: - link_text: The text of the element to partial match on. :Usage: driver.find_element_by_partial_link_text('Sign') """ return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text)
def find_element_by_partial_link_text(self, link_text): return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text)
def find_elements_by_partial_link_text(self, link_text): return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text)
def test_view_stats_admin(self): """ Log in as Admin Click on User Menu for drop-down Click on 'Admin' on user menu Click "Stats" Click "Concept Coach" ***The user is presented with Concept Coach Statistics (t2.07.01)*** Corresponds to... t2.07.01 :return: """ # t2.07.01 --> The user is presented with Concept Coach Statistics self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Stats') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Concept Coach') ) ).click() assert ('/stats/concept_coach' in self.admin.current_url()), \ 'Not viewing Concept Coach stats'
def filter_results(self, string: str): """ :param string: search for an element containing a specific string :type string: str """ self.wait_until_valid(By.PARTIAL_LINK_TEXT, string) self._driver.find_elements_by_partial_link_text(string)[0].click()
def _get_link(self, group): """Return the element linking to the users list dialog.""" print('\nNavigating to %s profile…' % self.target) self.driver.get('https://www.instagram.com/%s/' % self.target) try: return WebDriverWait(self.driver, 5).until( EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, group)) ) except: self._get_link(self.target, group)