diff --git a/lib/api/web-element/commands/isDisplayed.js b/lib/api/web-element/commands/isDisplayed.js new file mode 100644 index 0000000000..5c4f7f5fed --- /dev/null +++ b/lib/api/web-element/commands/isDisplayed.js @@ -0,0 +1,5 @@ +const IsVisibleCommand = require('./isVisible'); + +class IsDisplayedCommand extends IsVisibleCommand {} + +module.exports = IsDisplayedCommand; diff --git a/lib/api/web-element/commands/isVisible.js b/lib/api/web-element/commands/isVisible.js new file mode 100644 index 0000000000..dcee778497 --- /dev/null +++ b/lib/api/web-element/commands/isVisible.js @@ -0,0 +1,17 @@ +const BaseCommand = require('./_base'); +const { WEB_ELEMENT } = require('../../../../lib/transport/selenium-webdriver/method-mappings'); + +class IsVisibleCommand extends BaseCommand { + async execute() { + const { sessionId, id } = this.context; + try { + const isVisible = await this.transport.executeMethod(sessionId, WEB_ELEMENT.isVisible, { id }); + return isVisible; + } catch (error) { + console.error("Error checking element visibility:", error); + return false; + } + } +} + +module.exports = IsVisibleCommand;