Selenium_python 示例代码(1)
来源:互联网 发布:网络游戏编程 编辑:程序博客网 时间:2024/06/01 08:41
代码1:
#-*- coding:utf-8 -*-
from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://www.baidu.com") # Load page
assert "百度一下,你就知道" in browser.title
elem = browser.find_element_by_id("kw") # Find the query box
elem.send_keys("seleniumhq" + Keys.RETURN)
time.sleep(0.2) # Let the page load, will be added to the API
try:
browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")
except NoSuchElementException:
assert 0, "can't find seleniumhq"
browser.close()
代码2:
#-*- coding:utf-8 -*-
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Chrome() # Get local session of firefox
browser.get("http://www.baidu.com") # Load page
assert "百度一下,你就知道" in browser.title
elem = browser.find_element_by_id("kw") # Find the query box
elem.send_keys("seleniumhq" )
elem1=browser.find_element_by_id("su")
elem1.click()
time.sleep(0.2) # Let the page load, will be added to the API
try:
browser.find_element_by_xpath("//div[@class='floatTip']")
except NoSuchElementException:
assert 0, "can't find seleniumhq"
browser.close()
- Selenium_python 示例代码(1)
- Selenium_python 实例代码(1)
- Selenium_Python实例代码(2)
- Selenium_Python实例代码(2)
- Selenium_python实例代码(3)
- Selenium_python实例代码(3)
- SEH示例代码1
- 委托示例代码(1)
- python3代码示例1
- Selenium_python 方法调用
- webdriver cookie 处理 selenium_python
- eclipse + mapxtreme 代码示例1
- 代码示例1:抓取原代码
- tensorflow示例代码注释1
- webservice学习代码示例(1)
- 代码示例
- 代码示例
- 示例代码
- cocos2d-x 当中访问WebServer服务器的方法,以及解析XML文件.
- 针对mysql innodb配置的优化
- 修改mysql数据存储的地址
- HDU 4705 Y(简单树形DP)
- VC++多线程编程
- Selenium_python 示例代码(1)
- DISCUZ 3.0如何设置开启FLASH多媒体发帖功能
- hdu 1695 GCD(容斥定理)
- 播放简单音效
- 拖延心理学
- isolation_level
- xtrabackup-2.1.2-611安装
- 参考博客的网址总结(一)
- hdu3436Queue-jumpers(splay+离散化)