Commit 46947736 authored by Tricia Crichton's avatar Tricia Crichton Committed by Commit Bot

[ChromeDriver] Change window and element size in tests

Alter the element and window size to reduce flakiness of tests caused by
scrolling.

Bug: 1038366
Change-Id: I448ffd291a55d596f2a832021645061fde168931
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984533Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728030}
parent db8cf80a
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
background: blue; background: blue;
width: 300px; width: 300px;
height: 300px; height: 300px;
top: 300px; top: 150px;
left: 100px; left: 100px;
} }
...@@ -30,7 +30,7 @@ function testElementParentCenterLocation() { ...@@ -30,7 +30,7 @@ function testElementParentCenterLocation() {
var parent = document.getElementById('parent'); var parent = document.getElementById('parent');
var location = getElementLocation(parent, true); var location = getElementLocation(parent, true);
var x = 100 + 0.5 * 300; var x = 100 + 0.5 * 300;
var y = 300 + 0.5 * 300; var y = 150 + 0.5 * 300;
assertEquals(Math.floor(x), Math.floor(location.x)); assertEquals(Math.floor(x), Math.floor(location.x));
assertEquals(Math.floor(y), Math.floor(location.y)); assertEquals(Math.floor(y), Math.floor(location.y));
} }
...@@ -39,7 +39,7 @@ function testElementChildCenterLocation() { ...@@ -39,7 +39,7 @@ function testElementChildCenterLocation() {
var child = document.getElementById('child'); var child = document.getElementById('child');
var location = getElementLocation(child, true); var location = getElementLocation(child, true);
var x = 150 + 0.5 * 200; var x = 150 + 0.5 * 200;
var y = 360 + 0.5 * 100; var y = 210 + 0.5 * 100;
assertEquals(Math.floor(x), Math.floor(location.x)); assertEquals(Math.floor(x), Math.floor(location.x));
assertEquals(Math.floor(y), Math.floor(location.y)); assertEquals(Math.floor(y), Math.floor(location.y));
} }
...@@ -48,7 +48,7 @@ function testElementParentTopLeftLocation() { ...@@ -48,7 +48,7 @@ function testElementParentTopLeftLocation() {
var parent = document.getElementById('parent'); var parent = document.getElementById('parent');
var location = getElementLocation(parent, false); var location = getElementLocation(parent, false);
var x = 100; var x = 100;
var y = 300; var y = 150;
assertEquals(Math.floor(x), Math.floor(location.x)); assertEquals(Math.floor(x), Math.floor(location.x));
assertEquals(Math.floor(y), Math.floor(location.y)); assertEquals(Math.floor(y), Math.floor(location.y));
} }
...@@ -57,7 +57,7 @@ function testElementChildCenterTopLeftLocation() { ...@@ -57,7 +57,7 @@ function testElementChildCenterTopLeftLocation() {
var child = document.getElementById('child'); var child = document.getElementById('child');
var location = getElementLocation(child, false); var location = getElementLocation(child, false);
var x = 150; var x = 150;
var y = 360; var y = 210;
assertEquals(Math.floor(x), Math.floor(location.x)); assertEquals(Math.floor(x), Math.floor(location.x));
assertEquals(Math.floor(y), Math.floor(location.y)); assertEquals(Math.floor(y), Math.floor(location.y));
} }
...@@ -66,7 +66,7 @@ function testElementChildCenterTopLeftLocation() { ...@@ -66,7 +66,7 @@ function testElementChildCenterTopLeftLocation() {
<body> <body>
<h2>position: absolute;</h2> <h2>position: absolute;</h2>
<p>The Parent element has position: absolute.</p> <p>The Parent element has position: absolute.</p>
<div id="parent">Parent: position: absolute, top: 300px, left: 100px. <div id="parent">Parent: position: absolute, top: 150px, left: 100px.
<div id="child">Child: position: absolute, top: 60px, left: 50px.</div> <div id="child">Child: position: absolute, top: 60px, left: 50px.</div>
</div> </div>
</body> </body>
......
...@@ -80,8 +80,6 @@ _NEGATIVE_FILTER = [ ...@@ -80,8 +80,6 @@ _NEGATIVE_FILTER = [
'ChromeDriverPageLoadTimeoutTest.testRefreshWithPageLoadTimeout', 'ChromeDriverPageLoadTimeoutTest.testRefreshWithPageLoadTimeout',
# testFocus is failing # testFocus is failing
'JavaScriptTests.testFocus', 'JavaScriptTests.testFocus',
# https://bugs.chromium.org/p/chromium/issues/detail?id=1038366
'JavaScriptTests.testAllJS',
] ]
...@@ -237,6 +235,8 @@ _ANDROID_NEGATIVE_FILTER['chrome'] = ( ...@@ -237,6 +235,8 @@ _ANDROID_NEGATIVE_FILTER['chrome'] = (
'ChromeDriverTest.testPushAndNotificationsPermissions', 'ChromeDriverTest.testPushAndNotificationsPermissions',
'ChromeDriverTest.testSensorPermissions', 'ChromeDriverTest.testSensorPermissions',
'ChromeDriverTest.testSettingPermissionDoesNotAffectOthers', 'ChromeDriverTest.testSettingPermissionDoesNotAffectOthers',
# Android does not allow changing window size
'JavaScriptTests.*',
] ]
) )
_ANDROID_NEGATIVE_FILTER['chrome_stable'] = ( _ANDROID_NEGATIVE_FILTER['chrome_stable'] = (
...@@ -4212,6 +4212,7 @@ class JavaScriptTests(ChromeDriverBaseTestWithWebServer): ...@@ -4212,6 +4212,7 @@ class JavaScriptTests(ChromeDriverBaseTestWithWebServer):
def setUp(self): def setUp(self):
self._driver = self.CreateDriver() self._driver = self.CreateDriver()
self.js_root = os.path.dirname(os.path.realpath(__file__)) + '/../js/' self.js_root = os.path.dirname(os.path.realpath(__file__)) + '/../js/'
self._driver.SetWindowRect(1000, 1000, 0, 0)
def checkTestResult(self): def checkTestResult(self):
def getStatus(): def getStatus():
......
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