Run internet explorer as different user using Sele

2020-08-02 06:37发布

问题:

I want to launch single Internet explorer instane as different user with Selenium. I referred to the following post but not getting anywhere.

How can I run Internet Explorer Selenium tests as a specific domain user?

Can you point me in the right direction how it can be achieved?

回答1:

You can achieve that using URI authentication. For Google Chrome that behavior works without any additional changes, but for IE it blocked by default. You can unlock it by:

Set the DWORD value's value data to 1 in one of the following registry keys.

  • For all users of the program, set the value in the following registry key: HKEY_LOCAL_MACHINE\Software\Microsoft\Internet
    Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE
  • For the current user of the program only, set the value in the
    following registry key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE

After that you will be able to use next URI to achieve your needs: http://username:password@host/ If you want to provide domain name, you need encode that like http://domain%5Cusername:password@host/

Source https://support.microsoft.com/en-us/kb/834489