1+ import assert from 'node:assert/strict' ;
12import { describe , it , before , after } from 'node:test' ;
23
3- import { expect , use } from 'chai' ;
4- import chaiAsPromised from 'chai-as-promised' ;
54import type { Browser } from 'webdriverio' ;
65
76import { APIDEMOS_CAPS } from '../../desired.js' ;
87import { initSession , deleteSession } from '../../helpers/session.js' ;
98
10- use ( chaiAsPromised ) ;
11-
129describe ( 'Find - CSS' , function ( ) {
1310 let driver : Browser ;
1411 before ( async function ( ) {
@@ -18,56 +15,56 @@ describe('Find - CSS', function () {
1815 await deleteSession ( ) ;
1916 } ) ;
2017 it ( 'should find an element by id (android resource-id)' , async function ( ) {
21- await expect ( driver . $ ( '#android\\:id\\/text1' ) . elementId ) . to . eventually . exist ;
22- await expect ( driver . $ ( '*[id="android:id/text1"]' ) . elementId ) . to . eventually . exist ;
23- await expect ( driver . $ ( '*[resource-id="android:id/text1"]' ) . elementId ) . to . eventually . exist ;
18+ assert . ok ( ( await driver . $ ( '#android\\:id\\/text1' ) . elementId ) != null ) ;
19+ assert . ok ( ( await driver . $ ( '*[id="android:id/text1"]' ) . elementId ) != null ) ;
20+ assert . ok ( ( await driver . $ ( '*[resource-id="android:id/text1"]' ) . elementId ) != null ) ;
2421 } ) ;
2522 it ( 'should find an element by content description' , async function ( ) {
26- await expect ( driver . $ ( '*[description="Animation"]' ) . elementId ) . to . eventually . exist ;
23+ assert . ok ( ( await driver . $ ( '*[description="Animation"]' ) . elementId ) != null ) ;
2724 } ) ;
2825 it ( 'should return an array with findElements' , async function ( ) {
2926 const els = await driver . $$ ( '*[content-desc="Animation"]' ) ;
30- expect ( els ) . to . be . an . instanceof ( Array ) ;
31- expect ( els ) . to . have . length ( 1 ) ;
27+ assert . ok ( Array . isArray ( els ) ) ;
28+ assert . strictEqual ( els . length , 1 ) ;
3229 } ) ;
3330 it ( 'should find an element with a content-desc property containing an apostrophe' , async function ( ) {
34- await expect ( driver . $ ( '*[content-description="Access\'ibility"]' ) . elementId ) . to . eventually . exist ;
31+ assert . ok ( ( await driver . $ ( '*[content-description="Access\'ibility"]' ) . elementId ) != null ) ;
3532 } ) ;
3633 it ( 'should find an element by class name' , async function ( ) {
3734 const el = await driver . $ ( 'android.widget.TextView' ) ;
3835 const text = await el . getText ( ) ;
39- expect ( text . toLowerCase ( ) ) . to . equal ( 'api demos' ) ;
36+ assert . strictEqual ( text . toLowerCase ( ) , 'api demos' ) ;
4037 } ) ;
4138 it . skip ( 'should find an element with a chain of attributes and pseudo-classes' , async function ( ) {
4239 // TODO: webdriver selects 'class name' strategy.
4340 // ref. https://github.com/webdriverio/webdriverio/blob/eba541a77dbc42173717e1c106a7c4d3ccb198f5/packages/webdriverio/src/utils/findStrategy.ts#L91-L96
4441 const el = await driver . $ ( 'android.widget.TextView[clickable=true]:nth-child(1)' ) ;
45- await expect ( el . getText ( ) ) . to . eventually . equal ( 'Accessibility' ) ;
42+ assert . strictEqual ( await el . getText ( ) , 'Accessibility' ) ;
4643 } ) ;
4744 it ( 'should find an element with recursive UiSelectors' , async function ( ) {
4845 const els = await driver . $$ ( '*[focused=true] *[clickable=true]' ) ;
49- expect ( els ) . to . have . length ( 1 ) ;
46+ assert . strictEqual ( els . length , 1 ) ;
5047 } ) ;
5148 it ( 'should find an element by a non-fully qualified class name using CSS tag name' , async function ( ) {
5249 const els = await driver . $$ ( 'android.widget.TextView' ) ;
53- expect ( els . length ) . to . be . above ( 0 ) ;
50+ assert . ok ( ( await els . length ) > 0 ) ;
5451 } ) ;
5552 it ( 'should find elements using starts with attribute' , async function ( ) {
56- await expect ( driver . $ ( '*[description^="Animation"]' ) . elementId ) . to . eventually . exist ;
53+ assert . ok ( ( await driver . $ ( '*[description^="Animation"]' ) . elementId ) != null ) ;
5754 } ) ;
5855 it ( 'should find elements using ends with attribute' , async function ( ) {
59- await expect ( driver . $ ( '*[description$="Animation"]' ) . elementId ) . to . eventually . exist ;
56+ assert . ok ( ( await driver . $ ( '*[description$="Animation"]' ) . elementId ) != null ) ;
6057 } ) ;
6158 it ( 'should find elements using word match attribute' , async function ( ) {
62- await expect ( driver . $ ( '*[description~="Animation"]' ) . elementId ) . to . eventually . exist ;
59+ assert . ok ( ( await driver . $ ( '*[description~="Animation"]' ) . elementId ) != null ) ;
6360 } ) ;
6461 it ( 'should find elements using wildcard attribute' , async function ( ) {
65- await expect ( driver . $ ( '*[description*="Animation"]' ) . elementId ) . to . eventually . exist ;
62+ assert . ok ( ( await driver . $ ( '*[description*="Animation"]' ) . elementId ) != null ) ;
6663 } ) ;
6764 it ( 'should allow UiScrollable with unicode string' , async function ( ) {
6865 await driver . startActivity ( 'io.appium.android.apis' , '.text.Unicode' ) ;
6966 const selector = '*[text="عربي"]:instance(0)' ;
7067 const el = await driver . $ ( selector ) ;
71- await expect ( el . getText ( ) ) . to . eventually . equal ( 'عربي' ) ;
68+ assert . strictEqual ( await el . getText ( ) , 'عربي' ) ;
7269 } ) ;
7370} ) ;
0 commit comments