Selenium_python实例代码(3)
来源:互联网 发布:js触发a标签href跳转 编辑:程序博客网 时间:2024/05/16 18:00
#-*- coding:utf-8 -*-
from selenium import webdriver
import time
import os
dr=webdriver.Chrome()
file_path = 'file:///'+os.path.abspath('checkbox.html')
dr.get(file_path)
#选择所有的checkbox并勾选上
for i in range(1,4):
checkbox=dr.find_element_by_css_selector('input[id=c%d]'%i)
checkbox.click()
time.sleep(2)
#把页面上最后一个checkbox的勾去掉
dr.find_elements_by_css_selector('input[type=checkbox]').pop().click()
time.sleep(2)
from selenium import webdriver
import time
import os
dr=webdriver.Chrome()
file_path = 'file:///'+os.path.abspath('checkbox.html')
dr.get(file_path)
#选择所有的checkbox并勾选上
for i in range(1,4):
checkbox=dr.find_element_by_css_selector('input[id=c%d]'%i)
checkbox.click()
time.sleep(2)
#把页面上最后一个checkbox的勾去掉
dr.find_elements_by_css_selector('input[type=checkbox]').pop().click()
time.sleep(2)
dr.quit()
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
For instance, conside this page source:
<html> <body> <form id="loginForm"> <input name="username" type="text" /> <input name="password" type="password" /> <input name="continue" type="submit" value="Login" /> <input name="continue" type="button" value="Clear" /> </form></body><html>
The form elements can be located like this:
login_form = driver.find_element_by_xpath("/html/body/form[1]")login_form = driver.find_element_by_xpath("//form[1]")login_form = driver.find_element_by_xpath("//form[@id='loginForm']")
0 0
- Selenium_python实例代码(3)
- Selenium_python实例代码(3)
- Selenium_Python实例代码(2)
- Selenium_python 实例代码(1)
- Selenium_Python实例代码(2)
- Selenium_python 示例代码(1)
- Selenium_python 方法调用
- webdriver cookie 处理 selenium_python
- 基础学习笔记 + 代码实例 (3)
- Selenium_Java实例代码(3)
- Webdriver_Ruby实例代码(3)
- webdriver 验证码问题 selenium_python
- TreeSet代码实例(简单)
- Selenium_Java实例代码(2)
- Webdriver_Ruby实例代码(2)
- 决策树(Decision Tree)--python实例代码分析(3)
- 1-4-3代码实例(顺时针div环绕)
- 实例代码
- remove
- 黑马程序员——Objective-C学习之无序集合(NSSet\NSMutableSet)
- Selenium_Python实例代码(2)
- cocos2d-js中Chipmunk物理引擎相关(1)
- LISP基础
- Selenium_python实例代码(3)
- [PHP][PrestaShop]CSS/JS合并
- Chrome 扩展程序 最近历史 HistoryBar v1.2
- 清空的手机存储卡数据如何恢复呢
- impala compute 命令
- JSFL集合
- webview与js交互
- 定制SWT/RCP界面(java UI思路拓展rcp/swt)
- iOS 注册通知失败 with an alert but haven't received permission from the user to display alerts