Skip to content

Commit 3fb659b

Browse files
author
DavertMik
committed
added tests, reverted runok
1 parent ef8a203 commit 3fb659b

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

lib/locator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ Locator.clickable = {
446446
`.//*[@aria-label = ${literal}]`,
447447
`.//*[@title = ${literal}]`,
448448
`.//*[@aria-labelledby = //*[@id][normalize-space(string(.)) = ${literal}]/@id ]`,
449+
`.//*[@role='button'][normalize-space(.)=${literal}]`,
449450
]),
450451

451452
/**

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"@wdio/selenium-standalone-service": "8.15.0",
143143
"@wdio/utils": "9.15.0",
144144
"@xmldom/xmldom": "0.9.8",
145+
"bunosh": "latest",
145146
"chai": "^4.5.0",
146147
"chai-as-promised": "7.1.2",
147148
"chai-subset": "1.6.0",
@@ -165,7 +166,7 @@
165166
"puppeteer": "24.8.0",
166167
"qrcode-terminal": "0.12.0",
167168
"rosie": "2.1.1",
168-
"bunosh": "latest",
169+
"runok": "^0.9.3",
169170
"semver": "7.7.2",
170171
"sinon": "21.0.0",
171172
"sinon-chai": "3.7.0",

test/helper/webapi.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,4 +1894,81 @@ export function tests() {
18941894
await I.see('Software Engineer')
18951895
})
18961896
})
1897+
1898+
describe('aria selectors without role locators', () => {
1899+
it('should find clickable elements by aria-label', async () => {
1900+
await I.amOnPage('/form/role_elements')
1901+
1902+
await I.click('Reset')
1903+
await I.dontSeeInField('Title', 'Test')
1904+
1905+
await I.click('Submit Form')
1906+
await I.see('Form Submitted!')
1907+
})
1908+
1909+
it('should click elements by aria-label', async () => {
1910+
await I.amOnPage('/form/role_elements')
1911+
1912+
await I.fillField('Title', 'Test Title')
1913+
await I.fillField('Name', 'John Doe')
1914+
1915+
await I.click('Submit Form')
1916+
await I.see('Form Submitted!')
1917+
await I.see('Test Title')
1918+
await I.see('John Doe')
1919+
})
1920+
1921+
it('should fill fields by aria-label without specifying role', async () => {
1922+
await I.amOnPage('/form/role_elements')
1923+
1924+
await I.fillField('Title', 'Senior Developer')
1925+
await I.seeInField('Title', 'Senior Developer')
1926+
1927+
await I.fillField('Name', 'Jane Smith')
1928+
await I.seeInField('Name', 'Jane Smith')
1929+
1930+
await I.fillField('Category', 'Engineering')
1931+
await I.seeInField('Category', 'Engineering')
1932+
1933+
await I.fillField('your@email.com', 'test@example.com')
1934+
await I.seeInField('your@email.com', 'test@example.com')
1935+
1936+
await I.fillField('Enter your message', 'Hello World')
1937+
await I.seeInField('Enter your message', 'Hello World')
1938+
})
1939+
1940+
it('should check options by aria-label', async () => {
1941+
if (!isHelper('WebDriver')) return
1942+
1943+
await I.amOnPage('/form/role_elements')
1944+
1945+
await I.dontSeeCheckboxIsChecked('I agree to the terms and conditions')
1946+
await I.checkOption('I agree to the terms and conditions')
1947+
await I.seeCheckboxIsChecked('I agree to the terms and conditions')
1948+
1949+
await I.dontSeeCheckboxIsChecked('Subscribe to newsletter')
1950+
await I.checkOption('Subscribe to newsletter')
1951+
await I.seeCheckboxIsChecked('Subscribe to newsletter')
1952+
})
1953+
1954+
it('should interact with multiple elements using aria-label', async () => {
1955+
await I.amOnPage('/form/role_elements')
1956+
1957+
await I.fillField('Title', 'Product Manager')
1958+
await I.fillField('Name', 'Bob Johnson')
1959+
await I.fillField('Category', 'Product')
1960+
await I.fillField('your@email.com', 'bob@company.com')
1961+
await I.fillField('Enter your message', 'Test message')
1962+
1963+
if (isHelper('WebDriver')) {
1964+
await I.checkOption('Subscribe to newsletter')
1965+
}
1966+
1967+
await I.click('Submit Form')
1968+
await I.see('Form Submitted!')
1969+
await I.see('Product Manager')
1970+
await I.see('Bob Johnson')
1971+
await I.see('Product')
1972+
})
1973+
})
18971974
}

0 commit comments

Comments
 (0)