I have code that returns information about the user agent. I want to find the part that says MSIE 10.0 and if it does then write Internet Explorer 10.0 to the log file. Is there a way to do this without regular expressions? I'll use them if necessary, also I don't know if this string will always be same length so I don't think substring would be consistent.
Browser: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
This is the code that returns the string:
var js = driver as IJavaScriptExecutor;
const string script = "return navigator.userAgent"; // get the user agent
if (js != null)
{
var userAgent = (string) js.ExecuteScript(script);
Logger.Log(Loglevel.Debug, "Brower: {0}", userAgent);
}