Hallo Ich erhalte in meinem Code eine ungültige Eingabezeichenfolge und ich bin mir nicht sicher, wie ich sie beheben kann. Was ich einfach versuche, ist die Berechnung des Grundpreises und des Gesamtabschlags. Der Ausgang für die beiden ist £ ...Ungültige Eingabezeichenfolge beim Versuch, eine Währungsberechnung durchzuführen
Beispiel: Grundpreis £ 148.00 Discount £ 20
Wie behebe ich den Code unten, wie ich double.parse und Number bin mit:
public double CalculateBasePriceAndTotalDiscountFromBasket(string basketLocation)
{
var basketSummaryContent = _driver.FindElements(CommonPageElements.BasketSummaryContent);
var totalDiscountValue = _driver.FindElements(CommonPageElements.TotalDiscountValue);
if (basketLocation.ToLower() == "top")
{
string basketSummaryContentText =
basketSummaryContent[0].FindElement(CommonPageElements.BasePriceValue).Text;
double basketSummaryPrice = double.Parse(basketSummaryContentText, NumberStyles.AllowCurrencySymbol);
double totalDiscount = double.Parse(totalDiscountValue[0].Text, NumberStyles.AllowCurrencySymbol);
return basketSummaryPrice - totalDiscount;
}
else
{
string basketSummaryContentText =
basketSummaryContent[1].FindElement(CommonPageElements.BasePriceValue).Text;
double basketSummaryPrice = double.Parse(basketSummaryContentText, NumberStyles.AllowCurrencySymbol);
double totalDiscount = double.Parse(totalDiscountValue[1].Text, NumberStyles.AllowCurrencySymbol);
return basketSummaryPrice - totalDiscount;
}
}