1

I need to assert the styles of an element directly from the Dusk tests. In my application, I changed some styles of elements based on a specific condition. e.g. For invalid users, I changed the background to red. Now, I need to assert the css styles from Dusk.
Note that I don't want to check the class attribute. I want to check the styles that the class added to the element.

1 Answer 1

1

It has been solved. I used the web driver developed by Facebook. So, using it, I've selected the proper tag using xpath. Then, I get the stylesheet property of the selected tag using the web driver. Here is the source code. Note that adding the facebook web driver is required.

$the_tag = $browser->driver->findElements(WebDriverBy::xpath('//*[@class="user-item d-flex justify-content-between align-items-center mb-3"]'))[0];
$this->assertEquals($the_tag->getCSSValue("background"),"red");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.