Commit c03c03be authored by srawlins's avatar srawlins Committed by Commit bot

Add tests for clicking etc in Mobile Emulation and test

Review URL: https://codereview.chromium.org/538733002

Cr-Commit-Position: refs/heads/master@{#293346}
parent 388ac9eb
......@@ -9,7 +9,7 @@ DeviceMetrics::DeviceMetrics(int width, int height, double device_scale_factor)
height(height),
device_scale_factor(device_scale_factor),
mobile(false),
fit_window(true),
fit_window(false),
text_autosizing(true),
font_scale_factor(1) {}
......
......@@ -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."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment