Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if an element is clickable using Protractor test

I have an element that does not allow it to be clickable using CSS property pointer-events: none; How can I check whether that element is clickable or not as doing a .click() on the element throws an exception that I cannot catch UnknownError: unknown error: Element is not clickable at point The element is a link so I just want to check if the redirect happened but because of this error it ends the test right away and try catch cannot catch the exception.

like image 535
Encore PTL Avatar asked Jan 17 '26 15:01

Encore PTL


2 Answers

I don't know about protractor, but using plain JS you can do:

window.getComputedStyle(element).getPropertyValue('pointer-events') == 'none';

however support for getComputedStyle may not be available in all browsers you wish to support, see MDN compatibility matrix, which indicates no support in IE 8, however it may not support the pointer-events CSS property anyway.

like image 85
RobG Avatar answered Jan 20 '26 03:01

RobG


if you really want to use protractor you can use the following:

expect( protractor.ExpectedConditions.elementToBeClickable(element)).not.toBe(true);

like image 28
fSiq Avatar answered Jan 20 '26 03:01

fSiq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!