Skip to content

[Feature]: Add support to add assertion for css attributes of any element #35113

@vaibhrez12

Description

@vaibhrez12

🚀 Feature Request

Similar to text/value assertion, it will be helpful to have css assertions for UI elements specially for properties like background-color, font style and font size. Can be extended to other css properties if needed.

Example

Assertion for any element font and background color like below can be helpful in validating css properties.

  await expect(page.locator('#next')).toHaveCSS('background-color', 'rgb(255, 227, 230)');
  await expect(page.locator('#next')).toHaveCSS('font-style', '600 18px / 24px OpenSans, "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif');
  await expect(page.locator('#next')).toHaveCSS('font-size', '18px');

Motivation

This will help to validate css properties for UI element using record/replay.

Metadata

Metadata

Assignees

No one assigned

    Labels

    open-to-a-pull-requestThe feature request looks good, we are open to reviewing a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions