def testLoopWaitForLoopTimeout(self): """Tests that wait_for_loop timeout_in_secondss if video does not loop.""" action = loop.LoopAction(loop_count=2, selector='#video_1', timeout_in_seconds=1) action.WillRunAction(self._tab) self.assertFalse(self._tab.EvaluateJavaScript(VIDEO_1_LOOP_CHECK)) self.assertRaises(py_utils.TimeoutException, action.RunAction, self._tab)
def testLoopWithNoSelector(self): """Tests that with no selector Loop action loops first media element.""" action = loop.LoopAction(loop_count=2, selector='#video_1', timeout_in_seconds=10) action.WillRunAction(self._tab) action.RunAction(self._tab) # Assert only first video has played. self.assertTrue(self._tab.EvaluateJavaScript(VIDEO_1_LOOP_CHECK)) self.assertFalse(self._tab.EvaluateJavaScript(AUDIO_1_LOOP_CHECK))
def testLoopWithAllSelector(self): """Tests that Loop action loops all video elements with selector='all'.""" action = loop.LoopAction(loop_count=2, selector='all', timeout_in_seconds=10) action.WillRunAction(self._tab) # Both videos not playing before running action. self.assertFalse(self._tab.EvaluateJavaScript(VIDEO_1_LOOP_CHECK)) self.assertFalse(self._tab.EvaluateJavaScript(AUDIO_1_LOOP_CHECK)) action.RunAction(self._tab) # Assert all media elements played. self.assertTrue(self._tab.EvaluateJavaScript(VIDEO_1_LOOP_CHECK)) self.assertTrue(self._tab.EvaluateJavaScript(AUDIO_1_LOOP_CHECK))