Path: blob/trunk/javascript/selenium-webdriver/test/elementAriaRole_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 test = require('../lib/test')21const { By } = require('selenium-webdriver')2223test.suite(24function (env) {25let driver2627before(async function () {28driver = await env.builder().build()29})30after(() => driver.quit())3132describe('Testing Aria role', function () {33it('Should return explicitly defined role', async function () {34await driver.get(`data:text/html,<!DOCTYPE html>35<div role='heading' aria-level='1'>Level 1 Header</div>`)36let header = driver.findElement(By.css('div'))37assert.strictEqual(await header.getAriaRole(), 'heading')38})3940it('Should return implicit role defined by tagName', async function () {41await driver.get(`data:text/html,<!DOCTYPE html>42<h1> Level 1 Header</h1>`)43let header = driver.findElement(By.css('h1'))44assert.strictEqual(await header.getAriaRole(), 'heading')45})4647it('Should return explicit role even if it contradicts TagName', async function () {48await driver.get(`data:text/html,<!DOCTYPE html>49<h1 role='alert'>Level 1 Header</h1>`)50let header = driver.findElement(By.css('h1'))51assert.strictEqual(await header.getAriaRole(), 'alert')52})53})54},55{ browsers: ['chrome'] },56)575859