Bug 1277811 - Fix test_key_actions.py by scrolling element into view before press() is called. r?automatedtester draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 22 Aug 2016 14:07:51 +0200
changeset 403908 9d673760644be7d5a39ec23a1b3df505d7008c9c
parent 402150 97a52326b06a07930216ebefa5af333271578904
child 529030 8b2f7af83a10b1956e37ace3c189c52d8cd03e9a
push id27043
push userbmo:hskupin@gmail.com
push dateMon, 22 Aug 2016 12:08:13 +0000
reviewersautomatedtester
bugs1277811
milestone51.0a1
Bug 1277811 - Fix test_key_actions.py by scrolling element into view before press() is called. r?automatedtester MozReview-Commit-ID: J4X2TM5LeWF
testing/marionette/harness/marionette/tests/unit/test_key_actions.py
--- a/testing/marionette/harness/marionette/tests/unit/test_key_actions.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_key_actions.py
@@ -64,18 +64,21 @@ class TestKeyActions(MarionetteTestCase)
         (self.key_action.key_down(self.mod_key)
                         .key_down("a")
                         .wait(.5)
                         .key_down("x")
                         .perform())
         self.assertEqual(self.key_reporter_value, "")
 
     def test_open_in_new_window_shortcut(self):
+        start_win = self.marionette.current_chrome_window_handle
         el = self.marionette.find_element(By.ID, "updatediv")
-        start_win = self.marionette.current_chrome_window_handle
+        # Ensure that the element is in the current view port because press() doesn't
+        # handle that inside the action chain (bug 1295538).
+        self.marionette.execute_script('arguments[0].scrollIntoView()', script_args=[el])
         (self.key_action.key_down(Keys.SHIFT)
                         .press(el)
                         .release()
                         .key_up(Keys.SHIFT)
                         .perform())
         self.wait_for_condition(
             lambda mn: len(self.marionette.window_handles) == 2)
         chrome_window_handles = self.marionette.chrome_window_handles