-1

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?

wintermeyer
  • 7,536
  • 8
  • 34
  • 69

2 Answers2

1

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'))
wintermeyer
  • 7,536
  • 8
  • 34
  • 69
0

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.

ddavison
  • 25,442
  • 12
  • 70
  • 96
  • I need a test which tests the visual display (red and line-through). It is a test to check if the CSS works correct. – wintermeyer Mar 20 '14 at 12:38