Path: blob/trunk/javascript/selenium-webdriver/test/rect_test.js
2884 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617'use strict'1819const assert = require('node:assert')20const { By } = require('selenium-webdriver')21const test = require('../lib/test')2223test.suite(function (env) {24describe('WebElement', function () {25let driver2627before(async function () {28driver = await env.builder().build()29})3031after(function () {32return driver.quit()33})3435it('getRect()', async function () {36const html =37'<!DOCTYPE html><style>' +38'*{padding:0; margin:0}' +39'div{position: absolute; top: 50px; left: 40px;' +40'height: 25px;width:35px;background: green;}' +41'</style><div>Hello</div>'4243await driver.get(test.Pages.echoPage + `?html=${encodeURIComponent(html)}`)44const el = await driver.findElement(By.css('div'))45const rect = await el.getRect()46assert.deepStrictEqual(rect, { width: 35, height: 25, x: 40, y: 50 })47})48})49})505152