Skip to content
CodeKruPro

Get CSS Property Values

19/70

Get CSS Property Values

Playwright locators do not have a getCssValue() helper. To read a computed CSS property, run a small function on the element with locator.evaluate() (you used this earlier to read a tag name).

Example: const cursor = await btn.evaluate(el => getComputedStyle(el).cursor);

On the Buttons page, the disabled button (ID: disabledButton) has no custom cursor style, so the browser reports the computed default.

Task:

  1. Navigate to https://testkru.com/Elements/Buttons
  2. Find the disabled button
  3. Check if it is enabled using isEnabled()
  4. Get its cursor CSS value using evaluate

Expected output:

Enabled: false
Cursor: default