Files
eShopOnWeb/tests/FunctionalTests/Web/WebPageHelpers.cs
Steve Smith d2412a84a9 Fix Null Warnings (#874)
* Fixing null warnings

* Fix null warnings
Fix other compiler warnings
2023-03-20 11:52:14 -04:00

28 lines
864 B
C#

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;
}
}