Reputation: 1361
I have a test I want to make, but I'm really unsure if it can be achieved or not using codeception. Just FYI, I'm a beginner using this. Here's the thing I wanna do :
My HTML structure would look a bit like this :
<body>
<div class="stuff">
<div class="red-background">
<div class="other-stuff">
<p>I'm a lobster and I love blue dogs !</p>
</div>
</div>
</div>
</body>
Of course, the only place where the background is specified is on my "red-background" class, so the element I'm really targeting is the <p>
and it doesn't really have a red background.
Is there any way to achieve that "easily" ?
The only thing I thought about was using the getCSSValue() from selenium webdriver and having a recursive function calling the parents one by one until I get the color or find the end of my html.
Upvotes: 1
Views: 987
Reputation: 4173
You should be able to execute a script that returns your color.
The code should look like this:
$color = $I->executeJS("return jQuery('my_css_selector').css('background-color');");
This will return the background color in rgb, if you need to check it by name then you can add an array to map names to rgb.
Upvotes: 3