rect_test.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. 'use strict';
  18. const assert = require('assert');
  19. const {By} = require('..');
  20. const test = require('../lib/test');
  21. test.suite(function(env) {
  22. describe('rect commands', function() {
  23. let driver;
  24. let el;
  25. test.before(function*() {
  26. driver = yield env.builder().build();
  27. yield driver.get(
  28. 'data:text/html,<!DOCTYPE html><style>'
  29. + '*{padding:0; margin:0}'
  30. + 'div{position: absolute; top: 50px; left: 50px;'
  31. + 'height: 50px;width:50px;background: green;}'
  32. + '</style><div>Hello</div>');
  33. el = yield driver.findElement(By.css('div'));
  34. });
  35. after(function() {
  36. if (driver) {
  37. return driver.quit();
  38. }
  39. });
  40. test.it('WebElement.getLocation()', function*() {
  41. let location = yield el.getLocation();
  42. assert.equal(location.x, 50);
  43. assert.equal(location.y, 50);
  44. });
  45. test.it('WebElement.getSize()', function*() {
  46. let size = yield el.getSize();
  47. assert.equal(size.width, 50);
  48. assert.equal(size.height, 50);
  49. });
  50. });
  51. });