我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用selenium.common.exceptions.NoSuchFrameException()。
def frame(self, frame_reference): """ Switches focus to the specified frame, by index, name, or webelement. :Args: - frame_reference: The name of the window to switch to, an integer representing the index, or a webelement that is an (i)frame to switch to. :Usage: driver.switch_to.frame('frame_name') driver.switch_to.frame(1) driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0]) """ if isinstance(frame_reference, basestring) and self._driver.w3c: try: frame_reference = self._driver.find_element(By.ID, frame_reference) except NoSuchElementException: try: frame_reference = self._driver.find_element(By.NAME, frame_reference) except NoSuchElementException: raise NoSuchFrameException(frame_reference) self._driver.execute(Command.SWITCH_TO_FRAME, {'id': frame_reference})
def check_basic_ui(self): # ????????? try: self.browser.find_element_by_id('control-panel') except NoSuchElementException: self.fail('Please add a control panel') # ????????? try: self.browser.find_element_by_id('presentation-name') except NoSuchElementException: self.fail('Please add a presentation-name input') # ?????demo????? try: self.browser.switch_to.frame('impress-frame') self.browser.switch_to.parent_frame() except NoSuchFrameException: self.fail('Please add a impress-frame')
def __call__(self, driver): try: if isinstance(self.frame_locator, tuple): driver.switch_to.frame(_find_element(driver, self.frame_locator)) else: driver.switch_to.frame(self.frame_locator) return True except NoSuchFrameException: return False
def switch(self): try: self.driver.switch_to.frame(self.el) self.browser.default_context = False except NoSuchFrameException as e: raise UnknownFrameException(e)