Python + Selenium 实现登录Office 365
2014-11-22 11:26
477 查看
最近捡起之前用的Python + Selenium实现工作中需要的登录Office 365功能。(吐槽:国内网络真是卡,登录Office 365实属不易。另外Selenium这样的网站都要墙,无法理解,据说是用了Google的IP,whatever……)
试图研究一下Selenium和WebDriver的关系,看了官方的介绍,先摘录一段有趣的内容:Jump to 2008. The Beijing Olympics mark China’s arrival as a global power,massive mortgage default in the United States triggers the worst internationalrecession since the Great
Depression, The Dark Knight is viewed by every human(twice), still reeling from the untimely loss of Heath Ledger. But the mostimportant story of that year was the merging of Selenium and WebDriver.
我本来想研究当前的Selenium到底哪些是Webdriver哪些是原来的Selenium,但是后来发现两者似乎已经是融为一体的赶脚。可以从他们类的结构窥见一斑:
http://selenium.googlecode.com/git/docs/api/py/api.html
我的登录Office 365的核心代码如下,可以说非常简单:
其中让我折腾了很久的一个问题是,在输入密码后,一定要有send一个RETURN的步骤,不然点击登录按钮会没有响应,具体原因有待下回分解……
试图研究一下Selenium和WebDriver的关系,看了官方的介绍,先摘录一段有趣的内容:Jump to 2008. The Beijing Olympics mark China’s arrival as a global power,massive mortgage default in the United States triggers the worst internationalrecession since the Great
Depression, The Dark Knight is viewed by every human(twice), still reeling from the untimely loss of Heath Ledger. But the mostimportant story of that year was the merging of Selenium and WebDriver.
我本来想研究当前的Selenium到底哪些是Webdriver哪些是原来的Selenium,但是后来发现两者似乎已经是融为一体的赶脚。可以从他们类的结构窥见一斑:
http://selenium.googlecode.com/git/docs/api/py/api.html
我的登录Office 365的核心代码如下,可以说非常简单:
def login_o365(self): self.driver = webdriver.Firefox() self.driver.maximize_window() self.driver.get(self._login_url) time.sleep(5) self.driver.find_element(*self._login_username_field_locator).send_keys(self._login_username) time.sleep(1) self.driver.find_element(*self._login_password_field_locator).send_keys(self._login_password) time.sleep(1) self.driver.find_element(*self._login_password_field_locator).send_keys(Keys.RETURN) time.sleep(1) self.driver.find_element(*self._login_submit_button_locator).click() time.sleep(20) print 'Log in O365 successfully!'
其中让我折腾了很久的一个问题是,在输入密码后,一定要有send一个RETURN的步骤,不然点击登录按钮会没有响应,具体原因有待下回分解……
相关文章推荐
- Python + Selenium 实现登录Office 365
- python+selenium实现登录账户后自动点击
- [置顶] Webdriver(selenium2)基于Python脚本实现登录填写日志(分步讲解)
- Python使用selenium实现网页用户名 密码 验证码自动登录功能
- Python爬虫 Selenium实现自动登录163邮箱和Locating Elements介绍
- Python Selenium Cookie 绕过验证码实现登录
- selenium+python实现自动化登录的方法
- python+selenium实现登录账户
- Python+Selenium实现新浪微博自动登录
- python+selenium实现登录账户后自动点击的示例
- Selenium+phantomJS+Python 操作cookie实现自动登录(以音悦台为例)
- [Python爬虫] Selenium实现自动登录163邮箱和Locating Elements介绍
- Python Selenium实现自动登录163邮箱
- python+selenium实现京东自动登录及秒杀功能
- selenium+python实现自动登录脚本
- Python selenium实现微博自动登录的示例代码
- Python Selenium Cookie 绕过验证码实现登录示例代码
- selenium+python实现1688登录 —— iframe中元素获取
- Python+selenium实现登录脚本
- Python3-Selenium3使用PO设计模式(Page Object)实现简单的页面登录操作