webdriverio: [š Bug]: Eslint `await-thenable` rule doesn't recognise async commands
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
7.22.0 and 8.0.0-alpha.412
Node.js Version
18
Mode
Standalone Mode
Which capabilities are you using?
const capabilities = {
platformName: 'iOS',
'appium:app':
IOS_ZIP_PATH || 'https://github.com/appium/appium/raw/1.x/sample-code/apps/TestApp.app.zip',
'appium:automationName': 'XCUITest',
'appium:deviceName': IOS_DEVICE_NAME || 'iPhone 12',
'appium:platformVersion': IOS_PLATFORM_VERSION || '15.5',
}
What happened?
import { remote, RemoteOptions } from 'webdriverio'
const { IOS_ZIP_PATH, IOS_DEVICE_NAME, IOS_PLATFORM_VERSION } = process.env
const capabilities = {
platformName: 'iOS',
'appium:app':
IOS_ZIP_PATH || 'https://github.com/appium/appium/raw/1.x/sample-code/apps/TestApp.app.zip',
'appium:automationName': 'XCUITest',
'appium:deviceName': IOS_DEVICE_NAME || 'iPhone 12',
'appium:platformVersion': IOS_PLATFORM_VERSION || '15.5',
}
const wdOpts: RemoteOptions = {
port: 4723,
logLevel: 'info',
capabilities,
}
describe('ios', () => {
let driver: WebdriverIO.Browser | undefined
beforeAll(async () => {
driver = await remote(wdOpts)
expect(driver).toBeDefined()
})
afterEach(async () => {
await driver.deleteSession()
})
it('should type "Hello World!" and retrieve value in input', async () => {
const elementId = await driver.findElement('accessibility id', 'IntegerA')
driver.elementSendKeys(elementId.ELEMENT, 'Hello World!')
const elementValue = await driver.findElement('accessibility id', 'IntegerA')
const attr = await driver.getElementAttribute(elementValue.ELEMENT, 'value')
expect(attr).toEqual('Hello World!')
})
it('should click on "show alert" and read alert text', async () => {
const element = await driver.findElement('accessibility id', 'show alert')
await driver.elementClick(element.ELEMENT)
const alertText = await driver.getAlertText()
expect(alertText).toEqual(`Cool title this alert is so cool.`)
})
})
Ide shows Redundant 'await' for a non-promise type for driver.getElementAttribute and driver.getAlertText(), looking at the typing he is right:
/**
* Webdriver Protocol Command
*
* The Get Element Attribute command will return the attribute of a web element.
* @ref https://w3c.github.io/webdriver/#dfn-get-element-attribute
*
*/
getElementAttribute(elementId: string, name: string): string;
getAlertText(): string;
/**
* Webdriver Protocol Command
*
* The Send Alert Text command sets the text field of a window.prompt user prompt to the given value.
* @ref https://w3c.github.io/webdriver/#dfn-send-alert-text
*
*/
I have similar problem with element return by getElementAttribute:
TS2339: Property 'ELEMENT' does not exist on type 'ElementReference'.
I presume thereās something wrong, maybe wrong package ?
What is your expected behavior?
Typing to work well
How to reproduce the bug.
Copy the test, test it.
Try to remove, the await, it will break.
Relevant log output

Code of Conduct
- I agree to follow this projectās Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (12 by maintainers)
Using both in one repo shouldnāt be an issue, you can use the following structure:
If you want to place the test files next to the frontend code then thereās a bit of a challenge depending on your setup. The next release (v8) will allow you to import the global types instead which should solve such challenges.
I just had a check and :
This repository does only provide one typescript setup : https://github.com/webdriverio/appium-boilerplate/blob/main/tsconfig.json
This wonāt work for us as we store the react-native app and the e2e on the same repo, but thatās a whole topic on itās own, letās just ignore that.
It also use a deprecated version of appium , upgrading should be quite simple.
All those specs given here are gold, I will clone it and see if I can reproduce the typing issue.
And for sure I will learn them all.
Sorry, I had to rename the branch : https://github.com/pass-culture/pass-culture-app-native/pull/3838
I will have a look to the boilerplate. Thanks !
I used latest which is
7.22.0. The other version is not released yet.Can be many things, wrong TS setup may be one.
I am helping you here and just because I closed it doesnāt mean I leave you hanging. I think the best we can do is you providing a minimal reproducible example that I can check out and look into. What do you think?
This is a legit error, if you use
findElementthe WebDriver response doesnāt contain anELEMENT.Fixing this results in:
which does not have any TS errors.