Namespace: isDisplayed

isDisplayed

isDisplayed(driver, path, timeopt) → {Object|Error}

isDisplayed

Parameters:
Name Type Attributes Description
driver Object

webdriver object of web browser.

path Object

object of path type as xpath, id, className, tagName, name properties.

time Number <optional>

time is optional.This parameter represent for how much time user want to wait for "webElement". After time finish it returns error.

Returns:

returns Object of webElement & displayed value. If we pass time param & it will not get "webElement", it will return error.

Type
Object | Error

Examples

Examples usage of isDisplayed by HTML element xpath

 isDisplayed(driver, { xpath: '//*[@id="testXpath"]/div' }).then((webElement) => {
   // After resolve promise We'll get the "webElement" object for HTML element whose "xpath" we pass.
   // By the help of "webElement" we get that HTML element is displayed or not.
 }).catch((error) => {
   // handle error
 });

Examples usage of isDisplayed by HTML element id

 isDisplayed(driver, { id: 'testId' }).then((webElement) => {
   // After resolve promise We'll get the "webElement" object for HTML element whose "id" we pass.
   // By the help of "webElement" we get that HTML element is displayed or not.
 }).catch((error) => {
   // handle error
 });

Examples usage of isDisplayed by HTML element class

 isDisplayed(driver, { className: 'testClass' }).then((webElement) => {
   // After resolve promise We'll get the "webElement" object for HTML element whose "classname" we pass.
   // By the help of "webElement" we get that HTML element is displayed or not.
 }).catch((error) => {
   // handle error
 });

Examples usage of isDisplayed by HTML element tagName

 isDisplayed(driver, { tagName: 'span' }).then((webElement) => {
   // After resolve promise We'll get the "webElement" object for HTML element whose "tagname" we pass.
   // By the help of "webElement" we get that HTML element is displayed or not.
 }).catch((error) => {
   // handle error
 });

Examples usage of isDisplayed by name property of HTML element

 isDisplayed(driver, { name: 'testName' }).then((webElement) => {
   // After resolve promise We'll get the "webElement" object for HTML element whose "name" property we pass.
   // By the help of "webElement" we get that HTML element is displayed or not.
   // Similarly we can access elemets HTML by using any attribute which used in HTML element.
   // As we can pass title, for, alt etc. attributes of an HTML element.
 }).catch((error) => {
   // handle error
 });