How to skip a element location if it is not presented in the page and perform other actions?

I have a scenario in which i have to click a particular element if it is presented in the page else i have to skip and click other element in the page.when i checked the presence of the element in the page using isdisplayed() function it is throwing error as below…
Can’t locate an element by this strategy: Locator map:

native content: “ Close”
html content: “by id or name “closeButton””
I know that the particular element is not present over there that’s why gave in if block but still got the same error…

//code snippet
if (closeButton.isDisplayed()) {;
else{; //pausing the video; //playing the video; //closing the video player

help me out

Rather than looking for the element, look for ALL elements which match the locator. If the list of elements is zero then the element does not exist. If the list is greater then zero, i.e. one, then it exists.