This repository has been archived by the owner on May 22, 2018. It is now read-only.
forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EranMes, on behalf of Ken Kania: Add chrome-specific atom for checkin…
…g whether an element is clickable at a certain point. r13091
- Loading branch information
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
javascript/chrome-driver/test/is_element_clickable_test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2011 WebDriver committers | ||
Copyright 2011 Google Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<html> | ||
<head> | ||
<title>is_element_clickable_test.html</title> | ||
<script type="text/javascript" src="../../webdriver-bootstrap.js"> | ||
</script> | ||
<script type="text/javascript"> | ||
goog.require('goog.math.Coordinate'); | ||
goog.require('goog.testing.jsunit'); | ||
goog.require('webdriver.chrome'); | ||
</script> | ||
|
||
<script type="text/javascript"> | ||
function isClickable(elem, coord) { | ||
var result = webdriver.chrome.isElementClickable(elem, coord); | ||
console.log(result.message); | ||
return result.clickable; | ||
} | ||
|
||
function getMidClientRect(elem) { | ||
var rect = elem.getClientRects()[0]; | ||
var x = rect.left + (rect.right - rect.left) / 2; | ||
var y = rect.top + (rect.bottom - rect.top) / 2; | ||
return new goog.math.Coordinate(x, y); | ||
} | ||
|
||
function testElementIsClickable() { | ||
var elem = document.getElementById('1'); | ||
assertTrue(isClickable(elem, getMidClientRect(elem))); | ||
} | ||
|
||
function testNotClickableAtPoint() { | ||
var elem = document.getElementById('2'); | ||
var otherElem = document.getElementById('2b'); | ||
assertFalse(isClickable(elem, getMidClientRect(otherElem))); | ||
} | ||
|
||
function testElementIsClickableByDescendant() { | ||
var elem = document.getElementById('3'); | ||
var child = document.getElementById('4'); | ||
assertTrue(isClickable(elem, getMidClientRect(child))); | ||
} | ||
|
||
function testInvalidCoordinateIsNotClickable() { | ||
var elem = document.getElementById('1'); | ||
assertFalse(isClickable(elem, new goog.math.Coordinate(-1, -1))); | ||
} | ||
|
||
</script> | ||
</head> | ||
<body> | ||
<div id='1' style='background-color:black'>1</div> | ||
<div id='2' style='background-color:orange'>2</div> | ||
<div id='2b' style='background-color:purple'>2b</div> | ||
<div id='3' style='background-color:green'> | ||
<div>3</div> | ||
<div id='4' style='background-color:blue; position:relative; top:50px'> | ||
div | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|