C# 如何让SimpleImpersonation库以不同的用户身份打开chrome
我试图以不同的用户身份运行selenium测试用例。我看到一篇关于SimpleImpersonation库的堆栈溢出的文章。我以管理员身份运行visual studio,但我需要使用常规凭据从visual studio运行chrome。我成功地模拟为我的非管理员用户,但当我通过VisualStudio运行google chrome时,它仍然作为我的管理员帐户运行。如有任何帮助或建议,将不胜感激C# 如何让SimpleImpersonation库以不同的用户身份打开chrome,c#,.net,impersonation,C#,.net,Impersonation,我试图以不同的用户身份运行selenium测试用例。我看到一篇关于SimpleImpersonation库的堆栈溢出的文章。我以管理员身份运行visual studio,但我需要使用常规凭据从visual studio运行chrome。我成功地模拟为我的非管理员用户,但当我通过VisualStudio运行google chrome时,它仍然作为我的管理员帐户运行。如有任何帮助或建议,将不胜感激 var credentials = new UserCredentials("VT"
var credentials = new UserCredentials("VT", "joeclark", "Blah");
Impersonation.RunAsUser(credentials, LogonType.Interactive, () =>
{
// do whatever you want as this user.
FinanceTestCore.GetDriver = testHelpers.StartBrowser(runningLocal);
});
这是打开web浏览器的代码
public ChromeDriver StartBrowser(bool runningOnDevMachine = true, ChromeOptions options = null)
{
if (options == null)
{
options = new ChromeOptions();
}
options.AddArguments("start-maximized");
//if this is running on dev machine then dont run headless
if (!runningOnDevMachine)
{
options.AddArgument("--headless");
options.AddArgument("--window-size=1920x1080");
}
//return new ChromeDriver("C:\\TFS\\Net", options);
return new ChromeDriver("\\\\localhost\\TFS.NET", options);
}
也许这有助于: