Exemplo n.º 1
0
	def find_all_occurrences(self):
		self._handle_closed_window()
		self._driver.switch_to.default_content()
		try:
			for frame_index in FrameIterator(self._driver):
				search_regions = self._get_search_regions_in_curr_frame()
				for occurrence in self.find_all_in_curr_frame():
					if self._should_yield(occurrence, search_regions):
						occurrence.frame_index = frame_index
						yield occurrence
		except FramesChangedWhileIterating:
			# Abort this search.
			pass
Exemplo n.º 2
0
 def test_disappearing_frame(self):
     child_frame = Frame()
     first_frame = Frame(child_frame)
     driver = StubWebDriver(first_frame)
     # We allow precisely 2 frame switches: One to first_frame and one to
     # child_frame. After this, FrameIterator tries to switch back to
     # first_frame, to see whether it has other children besides child_frame.
     # This is where we raise a NoSuchFrameException (by limiting the num.
     # of frame switches to 2). This simulates a situation where first_frame
     # disappears during iteration.
     driver.switch_to = TargetLocatorFailingAfterNFrameSwitches(driver, 2)
     with self.assertRaises(FramesChangedWhileIterating):
         list(FrameIterator(driver))
Exemplo n.º 3
0
 def test_one_frame(self):
     driver = StubWebDriver(Frame())
     self.assertEqual([[], [0]], list(FrameIterator(driver)))
Exemplo n.º 4
0
 def test_only_main_frame(self):
     self.assertEqual([[]], list(FrameIterator(StubWebDriver())))
Exemplo n.º 5
0
 def test_complex(self):
     driver = StubWebDriver(Frame(Frame()), Frame())
     self.assertEqual([[], [0], [0, 0], [1]], list(FrameIterator(driver)))
Exemplo n.º 6
0
 def test_two_frames(self):
     driver = StubWebDriver(Frame(), Frame())
     self.assertEqual([[], [0], [1]], list(FrameIterator(driver)))