fix some issue and cover by test (#669)

This commit is contained in:
Cédric Michel
2022-01-25 16:50:15 +01:00
committed by GitHub
parent 6847cdaa0c
commit 87ae6c618c
14 changed files with 268 additions and 81 deletions

View File

@@ -0,0 +1,27 @@
using System.Text.RegularExpressions;
namespace Microsoft.eShopWeb.FunctionalTests.Web;
public static class WebPageHelpers
{
public static string TokenTag = "__RequestVerificationToken";
public static string GetRequestVerificationToken(string input)
{
string regexpression = @"name=""__RequestVerificationToken"" type=""hidden"" value=""([-A-Za-z0-9+=/\\_]+?)""";
return RegexSearch(regexpression, input);
}
public static string GetId(string input)
{
string regexpression = @"name=""Items\[0\].Id"" value=""(\d)""";
return RegexSearch(regexpression, input);
}
private static string RegexSearch(string regexpression, string input)
{
var regex = new Regex(regexpression);
var match = regex.Match(input);
return match.Groups.Values.LastOrDefault().Value;
}
}