"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/javascript/chrome-driver/test/is_element_clickable_test.html" (17 Feb 2023, 2514 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <!DOCTYPE html>
    2 <!--
    3 Copyright 2011 WebDriver committers
    4 Copyright 2011 Google Inc.
    5 
    6 Licensed under the Apache License, Version 2.0 (the "License");
    7 you may not use this file except in compliance with the License.
    8 You may obtain a copy of the License at
    9 
   10      http://www.apache.org/licenses/LICENSE-2.0
   11 
   12 Unless required by applicable law or agreed to in writing, software
   13 distributed under the License is distributed on an "AS IS" BASIS,
   14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15 See the License for the specific language governing permissions and
   16 limitations under the License.
   17 -->
   18 <html>
   19 <head>
   20   <title>is_element_clickable_test.html</title>
   21   <script type="text/javascript" src="test_bootstrap.js">
   22   </script>
   23   <script type="text/javascript">
   24     goog.require('goog.math.Coordinate');
   25     goog.require('goog.testing.jsunit');
   26     goog.require('webdriver.chrome');
   27   </script>
   28 
   29   <script type="text/javascript">
   30     function isClickable(elem, coord) {
   31       var result = webdriver.chrome.isElementClickable(elem, coord);
   32       console.log(result.message);
   33       return result.clickable;
   34     }
   35 
   36     function getMidClientRect(elem) {
   37       var rect = elem.getClientRects()[0];
   38       var x = rect.left + (rect.right - rect.left) / 2;
   39       var y = rect.top + (rect.bottom - rect.top) / 2;
   40       return new goog.math.Coordinate(x, y);
   41     }
   42 
   43     function testElementIsClickable() {
   44       var elem = document.getElementById('1');
   45       assertTrue(isClickable(elem, getMidClientRect(elem)));
   46     }
   47 
   48     function testNotClickableAtPoint() {
   49       var elem = document.getElementById('2');
   50       var otherElem = document.getElementById('2b');
   51       assertFalse(isClickable(elem, getMidClientRect(otherElem)));
   52     }
   53 
   54     function testElementIsClickableByDescendant() {
   55       var elem = document.getElementById('3');
   56       var child = document.getElementById('4');
   57       assertTrue(isClickable(elem, getMidClientRect(child)));
   58     }
   59 
   60     function testInvalidCoordinateIsNotClickable() {
   61       var elem = document.getElementById('1');
   62       assertFalse(isClickable(elem, new goog.math.Coordinate(-1, -1)));
   63     }
   64 
   65   </script>
   66 </head>
   67 <body>
   68   <div id='1' style='background-color:black'>1</div>
   69   <div id='2' style='background-color:orange'>2</div>
   70   <div id='2b' style='background-color:purple'>2b</div>
   71   <div id='3' style='background-color:green'>
   72     <div>3</div>
   73     <div id='4' style='background-color:blue; position:relative; top:50px'>
   74       div
   75     </div>
   76   </div>
   77 </body>
   78 </html>