i have a question... i write tests for a mobile app. And at this moment i compare the prices in different currencies like pound, euro, india and so on.... A possible comparison should be "now £1.678,95". It's no problem for me to cut the "now", to cut the whitespace - short, to get the string in a possible Int or Double formation. BUT now i'am in france. In France the formation is "maintenant 2 500,00 €". No problem with the "maintenant", no problem with the whitespace outside the price and no Problem with "€".
BUT there is a space IN the price between 2 and 500. If i run my test, i have only the "2" the rest is gone! How can i do it, that the whitespace should not cut here. It should backspaced from "2 500,00" to "2500,00".
Hope you have an idea :) Thanks!
My code at this moment is :
var firstPrice = XCUIApplication().collectionViews.cells.element(boundBy: 0).staticTexts.element(boundBy: 2).label
firstPrice = firstPrice.replacingOccurrences(of: "£", with: "")
firstPrice = firstPrice.replacingOccurrences(of: "€", with: "")
firstPrice = firstPrice.replacingOccurrences(of: "₹", with: "")
let firstPriceArray = firstPrice.components(separatedBy: .whitespaces).filter { !$0.isEmpty }
firstPrice = firstPriceArray[1]
let firstPriceTrimmedDouble = firstPrice.toDouble(with: SiteIDHelper.locale(from: SiteIDHelper.SiteID(rawValue: Int(sideIDS))!))!
print(firstPriceTrimmedDouble)
Aucun commentaire:
Enregistrer un commentaire