Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何让SimpleImpersonation库以不同的用户身份打开chrome_C#_.net_Impersonation - Fatal编程技术网

C# 如何让SimpleImpersonation库以不同的用户身份打开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"

我试图以不同的用户身份运行selenium测试用例。我看到一篇关于SimpleImpersonation库的堆栈溢出的文章。我以管理员身份运行visual studio,但我需要使用常规凭据从visual studio运行chrome。我成功地模拟为我的非管理员用户,但当我通过VisualStudio运行google chrome时,它仍然作为我的管理员帐户运行。如有任何帮助或建议,将不胜感激

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); 
        }
也许这有助于: