-4

So I'm writing automated tests in Kotlin + Selenide for the pricing. I have 59 items in the cart. Each item is coded like this:

<div class="review-submit-list-total"><!-- react-text: 5 -->$<!-- /react-text --><!-- react-text: 6-->33.00<!-- /react-text --></div>

I get the price by val price1 = $(#some-locator).text it returns price as "$33.00". I need to get all the prices and then calculate them.

Would appreciate any ideas. Thanks.

zsmb13
  • 85,752
  • 11
  • 221
  • 226
Viterzgir
  • 212
  • 4
  • 14
  • yeah, more downvotes please. At least explain why do you downvote it, please. – Viterzgir Jul 03 '17 at 01:43
  • 1
    I didn't downvote, but this doesn't look like java to me..... –  Jul 03 '17 at 03:54
  • @Tommy, yeah, `val price1 = $(#some-locator).text` is written in Kotlin but since Java and Kotlin can be mixed in one class it was totally fine to me to get an example in Java :) also, Kotlin might have not such big community as Java so I could have higher changes to get an answer. – Viterzgir Jul 03 '17 at 04:06
  • 1
    You shouldn't tag a question just so it gets more attention. Please only use tags that are directly relevant. If you fear your question does not get enough attention you can set a bounty for it when you get higher reputation. Keep building up that reputation! –  Jul 03 '17 at 04:12

1 Answers1

2

Found an answer by myself:

val price1 = "$3999.00"     
val p1 = price1.replace("$", "")
val p2 = p1.toFloat()
Viterzgir
  • 212
  • 4
  • 14
  • 2
    Careful using floating point for monetary values - take a look at https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency – Greg Kopff Jul 03 '17 at 03:05