Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7191)

Unified Diff: chrome/test/chromedriver/test/run_py_tests.py

Issue 848483002: [chromedriver] Use center of first ClientRect when moving mouse to an element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add some extra checks to testMoveToElementAndClick Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/test/run_py_tests.py
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py
index e41c0268b82f07d582f59d5ba933dd37ff0429ab..fd46b0652a1a92994eafcfc67457b38279b735e3 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -562,6 +562,29 @@ class ChromeDriverTest(ChromeDriverBaseTest):
self._driver.MouseMoveTo(div, 10, 10)
self.assertEquals(1, len(self._driver.FindElements('tag name', 'br')))
+ def testMoveToElementAndClick(self):
+ self._driver.Load(self.GetHttpUrlForFile('/chromedriver/multiline.html'))
+
+ # Check that link element spans two lines and that the first ClientRect is
+ # above the second.
+ link = self._driver.FindElements('tag name', 'a')[0]
+ client_rects = self._driver.ExecuteScript(
+ 'return arguments[0].getClientRects();', link)
+ self.assertEquals(2, len(client_rects))
+ self.assertTrue(client_rects[0]['bottom'] < client_rects[1]['top'])
+
+ # Check that the center of the link's bounding ClientRect is outside the
+ # element.
+ bounding_client_rect = self._driver.ExecuteScript(
+ 'return arguments[0].getBoundingClientRect();', link)
+ center = bounding_client_rect['left'] + bounding_client_rect['width'] / 2
+ self.assertTrue(client_rects[1]['right'] < center)
+ self.assertTrue(center < client_rects[0]['left'])
+
+ self._driver.MouseMoveTo(link)
+ self._driver.MouseClick()
+ self.assertTrue(self._driver.GetCurrentUrl().endswith('#top'))
+
def testMouseClick(self):
div = self._driver.ExecuteScript(
'document.body.innerHTML = "<div>old</div>";'

Powered by Google App Engine
This is Rietveld 408576698