Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/test/rect_test.js
2884 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
'use strict'
19
20
const assert = require('node:assert')
21
const { By } = require('selenium-webdriver')
22
const test = require('../lib/test')
23
24
test.suite(function (env) {
25
describe('WebElement', function () {
26
let driver
27
28
before(async function () {
29
driver = await env.builder().build()
30
})
31
32
after(function () {
33
return driver.quit()
34
})
35
36
it('getRect()', async function () {
37
const html =
38
'<!DOCTYPE html><style>' +
39
'*{padding:0; margin:0}' +
40
'div{position: absolute; top: 50px; left: 40px;' +
41
'height: 25px;width:35px;background: green;}' +
42
'</style><div>Hello</div>'
43
44
await driver.get(test.Pages.echoPage + `?html=${encodeURIComponent(html)}`)
45
const el = await driver.findElement(By.css('div'))
46
const rect = await el.getRect()
47
assert.deepStrictEqual(rect, { width: 35, height: 25, x: 40, y: 50 })
48
})
49
})
50
})
51
52