如何获取SimpleImpersonation库以其他用户身份打开chrome

问题描述

我正在尝试以其他用户身份运行硒测试用例。我看到了一篇关于SimpleImpersonation库的堆栈溢出文章。我以管理员身份运行Visual Studio,但我需要使用常规凭据在Chrome浏览器之外运行chrome。我已经成功地以非管理员身份模拟,但是当我通过Visual Studio运行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); 
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...