Question

I need to test if the following HTML code and the CSS of that page results into a red and line-through price like:

enter image description here

<div class="listOldPrice">
  <span>
    <span class="wasPriceEuroDestination">&euro;&nbsp;</span>
    719.
    <b>-</b>
  </span>
</div>

Can I do that with Selenium? How?

Était-ce utile?

La solution

This is the Ruby solution:

price = @driver.find_element(:class, 'wasPriceEuroDestination')
assert_equal(true, price.displayed?)
assert_equal("rgba(255, 0, 0, 1)", price.css_value('color'))
assert_equal("line-through", price.css_value('text-decoration'))

Autres conseils

That is usually handled by a class. Since classes aren't the prettiest to match on since they aren't very unique, it's difficult to give you a complete selector, but i'll put some placeholders in:

In Java, you could do something like:

assertTrue(driver.findElement(By.cssSelector("div#someParentOfThatPrice div.listOldPrice")).isDisplayed());

If this test fails, that means that it can't find the element, ergo, it's not crossed out.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top