Selenium IE以不同的用户

时间:2018-02-06 14:38:37

标签: python selenium

您好我想使用selenium作为不同的用户打开Internet Explorer-11。我做了一个搜索,它表明它是可能的,但使用Java,我使用的是Python,所以我想知道是否可以使用Internet Explorer webdriver。

例如,如果您右键单击Internet Explorer,它将以不同的用户身份登录。我想用python IE webdriver自动化那部分,但我不知道该怎么做。

我的要求与此帖How to impersonate a specific user with Selenium Webdriver?类似 但我想用selenium webdriver在Python中做到这一点

要清楚。我知道如何用硒打开webrowser,我知道如何使用selenium登录(当有一个弹出窗口时)。但我问的是如何让selenium知道我想以不同的用户身份登录。因为如果我只是打开我的浏览器通常没有弹出登录。

from selenium import webdriver
driver=webdriver.Ie()

this is the desktop that is opened by selenium- there is no pop up for sign in

谢谢

2 个答案:

答案 0 :(得分:1)

您可以使用Selenium Web Driver

了解它,您可以使用与此类似的代码执行您所需的操作:

username = selenium.find_element_by_id("username")
password = selenium.find_element_by_id("password")

username.send_keys("YourUsername")
password.send_keys("yourPa55worD")

selenium.find_element_by_name("submit").click()

由于您似乎想要使用其他操作系统用户,我建议您使用Sikuli

  

Sikuli自动化您在屏幕上看到的任何内容。它使用图像识别来识别和控制GUI组件。当无法轻松访问GUI的内部或源代码时,它非常有用。

我认为没有办法只用Selenium做你想要的东西。如果您需要集成Selenium和Sikuli,您可以在SOF上看到这篇文章:Calling to a Sikuli script from Python (Selenium)。它可以为你提供一些想法。

我希望它有所帮助。

答案 1 :(得分:-1)

根据您的操作系统(Windows 32或64位)下载IE驱动程序

一个。 Download  Windows 32位驱动程序

OR

Download Windows 64位驱动程序

解压缩zip并将IEDriverServer.exe文件复制到某个位置,例如E:\ IEDriver

编写以下脚本

from selenium import webdriver browser = webdriver.Ie("e:\\IEDriver\\IEDriverServer.exe")

发送您的输入值'用户名'和密码'并提交。

运行脚本,应该打开IE浏览器......