使用Java中的Selenium Webdriver以不同的用户身份运行IE [英] Running IE as a different user with Selenium Webdriver in Java
问题描述
有没有人知道如何使用JAVA利用以不同用户身份运行功能运行IE会话?我不知道我怎么设置这个并且谷歌没有提出任何东西所以也许我在某处搜索错误的东西?
Does anyone know how I could get selenium to run an IE session utilising the "Run as different user" function using JAVA? I have no idea how I'd even go about setting this and google isn't bringing up anything so maybe I'm searching for the wrong thing somewhere?
要扩展为什么我需要这样做,我正在测试的网站是一个内部平台,并使用用户登录凭据/ Windows帐户详细信息来确定他们的角色,他们有什么链接,他们可以查看的数据等。
To expand a bit on why I need to do this, the website I'm testing is an internal platform and uses a users login credentials/windows account details to determine their role, what links they have, data they can view etc.
目前我作为特定用户(经理,数据管理员等)运行测试的唯一方法是在运行测试之前以该用户身份登录计算机。当我有多个用户帐户要测试并且正在使用GRID2运行Webdriver时,这实际上是不可能的(因此我有一组计算机在队列中出现测试时)。
Currently the only way I can run a test as a specific user (manager, data administrator etc) is to log into the machine as that user before running the test. This isn't really possible when I have multiple user accounts to test and am running Webdriver with GRID2 (so I have a bank of machines picking up tests from a queue as they come up).
手动运行测试时,我只需右键单击并选择ie快捷键上的以不同用户身份运行选项,因此想想我是否可以通过webdriver运行它来找到复制它的方法,这样可以解决我的问题。
When running tests manually I can simply right click and select the "run as different user" option on the ie shortcut, so figured if I could find a way to replicating this when running it via webdriver this would solve my problem.
感谢您的任何建议或帮助。
Thanks for any suggestions or assistance.
推荐答案
如果更糟最糟糕的是,您可以使用不同的用户名和密码设置文件,读入它们,通过工厂类确定所需的用户,然后根据您需要查看的参数选择每个测试的用户。如果你这样做,当你在多线程上运行时,它仍然会引导正确的用户登录。
If worse comes to worst, you could just setup a file with your different usernames and passwords, read them in, determine the user you need through a factory class, and then select the user per test based on the parameters you need to look at. If you do it this way, when you are running on multi-threads, it will still pull in the correct user to login with.
我不认为这是您的主要目标,但至少是次要解决方案。
I don't think this is your primary goal, but a secondary solution at minimum.
这篇关于使用Java中的Selenium Webdriver以不同的用户身份运行IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!