2013-08-31 61 views
2

我正在尝试使用Python打开一个IE实例,导航到特定的站点并输入登录凭据。我目前正在努力使IEC工作,但我也接受其他做同样事情的选择。Python和Internet Explorer(特定网站)

我有麻烦的最后一部分(登录),因为“按钮”似乎不被认为是这样的。它似乎是某种触发器作为一个按钮(角色=“按钮”)?我不是很熟悉:

<a title="Click here to log in." class="focus-parent ajax-request need-focus-pageobject" role="button" href="../MyAccount/MyAccountUserLogin.asp?Referrer=&AjaxRequest=true"> 

这是我曾尝试代码:

import IEC 

ie = IEC.IEController() 
ie.Navigate('https://efun.toronto.ca/torontofun/Start/Start.asp') 
ie.PollWhileBusy() 
# code after here does not work properly 
ie.Navigate('https://efun.toronto.ca/torontofun/MyAccount/MyAccountUserLogin.asp?Referrer=&AjaxRequest=true') 
ie.ClickButton(caption='toolbar-login') 
ie.SetInputValue('ClientBarcode', '123') 
ie.SetInputValue('AccountPIN', 'XYZ') 
ie.ClickButton(name='Enter') 

我想知道关于如何在这种情况下,打开登录菜单提示。

回答

0

你试过selenium

from selenium import webdriver 
driver = webdriver.Ie() 

login_btn = driver.find_element_by_id("toolbar-login") 
login_btn.send_keys(Keys.RETURN) 

user_name = driver.find_element_by_id("ClientBarcode") 
user_name.sendKeys("user") 
user_name.sendKeys(Keys.RETURN) 
+0

感谢您的回复。我看到硒,但没有尝试过。我想要一些可以直接控制IE的东西,我不认为硒可以做到这一点。 (我认为这主要是使用文本回复等自动化过程)我误解了硒的能力? – Roberto

+0

我不确定这个问题,但没有提到这个问题,所以我认为硒可能是一个选择 –