|
| 1 | +/* |
| 2 | + * Licensed to the Software Freedom Conservancy (SFC) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The SFC licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. 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, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +'use strict' |
| 21 | + |
| 22 | +const assert = require('assert') |
| 23 | +const test = require('../lib/test') |
| 24 | +const { By } = require('../index') |
| 25 | + |
| 26 | +test.suite( |
| 27 | + function (env) { |
| 28 | + let driver |
| 29 | + |
| 30 | + before(async function () { |
| 31 | + driver = await env.builder().build() |
| 32 | + }) |
| 33 | + after(() => driver.quit()) |
| 34 | + |
| 35 | + describe('Testing Aria role', function () { |
| 36 | + it('Should return explicitly defined role', async function () { |
| 37 | + await driver.get(`data:text/html,<!DOCTYPE html> |
| 38 | + <div role='heading' aria-level='1'>Level 1 Header</div>`) |
| 39 | + let header = driver.findElement(By.css('div')) |
| 40 | + assert.equal(await header.getAriaRole(), 'heading') |
| 41 | + }) |
| 42 | + |
| 43 | + it('Should return implicit role defined by tagName', async function () { |
| 44 | + await driver.get(`data:text/html,<!DOCTYPE html> |
| 45 | + <h1> Level 1 Header</h1>`) |
| 46 | + let header = driver.findElement(By.css('h1')) |
| 47 | + assert.equal(await header.getAriaRole(), 'heading') |
| 48 | + }) |
| 49 | + |
| 50 | + it('Should return explicit role even if it contradicts TagName', async function () { |
| 51 | + await driver.get(`data:text/html,<!DOCTYPE html> |
| 52 | + <h1 role='alert'>Level 1 Header</h1>`) |
| 53 | + let header = driver.findElement(By.css('h1')) |
| 54 | + assert.equal(await header.getAriaRole(), 'alert') |
| 55 | + }) |
| 56 | + }) |
| 57 | + }, |
| 58 | + { browsers: ['chrome'] } |
| 59 | +) |
0 commit comments