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

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

Issue 538733002: Add tests for clicking etc in Mobile Emulation and test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/test/chromedriver/chrome/device_metrics.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d8434411ca207c8e5d3c83b8c65d6f8800224ce4..2b106a6783a372544520a9fcae0f182b673be9e2 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -871,6 +871,75 @@ class MobileEmulationCapabilityTest(ChromeDriverBaseTest):
'5.19',
body_tag.GetText())
+ def testSendKeysToElement(self):
+ driver = self.CreateDriver(
+ mobile_emulation = {'deviceName': 'Google Nexus 5'})
+ text = driver.ExecuteScript(
+ 'document.body.innerHTML = \'<input type="text">\';'
+ 'var input = document.getElementsByTagName("input")[0];'
+ 'input.addEventListener("change", function() {'
+ ' document.body.appendChild(document.createElement("br"));'
+ '});'
+ 'return input;')
+ text.SendKeys('0123456789+-*/ Hi')
+ text.SendKeys(', there!')
+ value = driver.ExecuteScript('return arguments[0].value;', text)
+ self.assertEquals('0123456789+-*/ Hi, there!', value)
+
+ def testHoverOverElement(self):
+ driver = self.CreateDriver(
+ mobile_emulation = {'deviceName': 'Google Nexus 5'})
+ div = driver.ExecuteScript(
+ 'document.body.innerHTML = "<div>old</div>";'
+ 'var div = document.getElementsByTagName("div")[0];'
+ 'div.addEventListener("mouseover", function() {'
+ ' document.body.appendChild(document.createElement("br"));'
+ '});'
+ 'return div;')
+ div.HoverOver()
+ self.assertEquals(1, len(driver.FindElements('tag name', 'br')))
+
+ def testClickElement(self):
+ driver = self.CreateDriver(
+ mobile_emulation = {'deviceName': 'Google Nexus 5'})
+ div = driver.ExecuteScript(
+ 'document.body.innerHTML = "<div>old</div>";'
+ 'var div = document.getElementsByTagName("div")[0];'
+ 'div.addEventListener("click", function() {'
+ ' div.innerHTML="new<br>";'
+ '});'
+ 'return div;')
+ div.Click()
+ self.assertEquals(1, len(driver.FindElements('tag name', 'br')))
+
+ def testSingleTapElement(self):
+ driver = self.CreateDriver(
+ mobile_emulation = {'deviceName': 'Google Nexus 5'})
+ div = driver.ExecuteScript(
+ 'document.body.innerHTML = "<div>old</div>";'
+ 'var div = document.getElementsByTagName("div")[0];'
+ 'div.addEventListener("touchend", function() {'
+ ' div.innerHTML="new<br>";'
+ '});'
+ 'return div;')
+ div.SingleTap()
+ self.assertEquals(1, len(driver.FindElements('tag name', 'br')))
+
+ def testTouchDownUpElement(self):
+ driver = self.CreateDriver(
+ mobile_emulation = {'deviceName': 'Google Nexus 5'})
+ div = driver.ExecuteScript(
+ 'document.body.innerHTML = "<div>old</div>";'
+ 'var div = document.getElementsByTagName("div")[0];'
+ 'div.addEventListener("touchend", function() {'
+ ' div.innerHTML="new<br>";'
+ '});'
+ 'return div;')
+ loc = div.GetLocation()
+ driver.TouchDown(loc['x'], loc['y'])
+ driver.TouchUp(loc['x'], loc['y'])
+ self.assertEquals(1, len(driver.FindElements('tag name', 'br')))
+
class ChromeDriverLogTest(unittest.TestCase):
"""Tests that chromedriver produces the expected log file."""
« no previous file with comments | « chrome/test/chromedriver/chrome/device_metrics.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698