Mayra_Tabares:
I would like to know how I can validate if an element exists in order to click it, I need to get a boolean value to know it. If the button exists I need to click it if not I need to skip the click() process.
I’m using appium with typescript
you can use the isElementDisplayed function to check if an element exists and is displayed on screen.
something like this :
try {
const button = await driver.findElement(By.id(‘your-button-id’));
const isDisplayed = await button.isDisplayed();
if (isDisplayed) {
await button.click();
console.log('Button clicked!');
} else {
console.log('Button does not exist or is not displayed.');
}
} catch (error) {
console.log(‘Error occurred while validating and clicking the button:’, error);
}
give a look to this https://stackoverflow.com/questions/25753014/selenium-webdriver-wait-till-element-is-displayed