#coding=utf-8
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.baidu.com") # 获得输入框尺寸
size = driver.find_element_by_id("kw").size
print size #返回百度页面底部备案信息 text = driver.find_element_by_id("cp").text
print text #返回元素的属性值,可以是id、name、type 或元素拥有的其它任意属性 attribute = driver.find_element_by_id("kw").get_attribute('type')
print attribute #返回元素的结果是否可见,返回结果为True 或False
result = driver.find_element_by_id("kw").is_displayed()
print result driver.quit()

Python+Selenium 自动化实现实例-获取页面元素信息(百度首页)的更多相关文章

  1. Python+Selenium 自动化实现实例-获取测试对象的Css属性

    #coding:utf-8 '''获取测试对象的css属性场景 当你的测试用例纠结细枝末节的时候,你就需要通过判断元素的css属性来验证你的操作是否达到了预期的效果.比如你可以通过判断页面上的标题字号 ...

  2. Python+Selenium 自动化实现实例-Css捕捉元素的几种方法

    #coding=utf-8 from selenium import webdriverimport timedriver = webdriver.Chrome()driver.get("h ...

  3. Python+Selenium 自动化实现实例-Link 捕捉元素的几种方法

    from selenium import webdriver driver = webdriver.Chrome() driver.get("http://www.baidu.com&quo ...

  4. Python+Selenium 自动化实现实例-Xpath捕捉元素的几种方法

    #coding=utf-8import timefrom selenium import webdriverdriver = webdriver.Chrome()driver.get("ht ...

  5. python+selenium高亮显示正在操作的页面元素

    原文地址:https://blog.csdn.net/wxstar8/article/details/80801405 from selenium import webdriver import un ...

  6. Python+Selenium 自动化实现实例-定位frame中的元素

    场景 处理frame需要用到2个方法,分别是switch_to_frame(name_or_id_or_frame_element)和switch_to_default_content() 如何理解这 ...

  7. Python+Selenium 自动化实现实例-处理分页(pagination)

    场景 对分页来说,我们最感兴趣的是下面几个信息 总共有多少页 当前是第几页 是否可以上一页和下一页 代码 下面代码演示如何获取分页总数及当前页数.跳转到指定页数 #coding:utf-8 from ...

  8. Python+Selenium 自动化实现实例-实现文件下载

    #coding=utf-8 from selenium import webdriver #实例化一个火狐配置文件 fp = webdriver.FirefoxProfile() #设置各项参数,参数 ...

  9. Python+Selenium 自动化实现实例-定位一组对象(checkbox,inputs)

    # -*- coding: utf-8 -*- from selenium import webdriver import time import os dr = webdriver.Chrome() ...

随机推荐

  1. BZOJ4144 [AMPPZ2014]Petrol 【最短路 + 最小生成树】

    题目链接 BZOJ4144 题解 这题好妙啊,,orz 假设我们在一个非加油站点,那么我们一定是从加油站过来的,我们剩余的油至少要减去这段距离 如果我们在一个非加油站点,如果我们到达不了任意加油站点, ...

  2. MySQL5.6之Index Condition Pushdown(ICP,索引条件下推)-Using index condition

    http://blog.itpub.net/22664653/viewspace-1210844/ -- 这篇博客写的更细,以后看 ICP(index condition pushdown)是mysq ...

  3. bzoj1778: [Usaco2010 Hol]Dotp 驱逐猪猡(概率DP+高斯消元)

    深夜肝题...有害身心健康QAQ 设f[i]为到达i的概率,d[i]为i的度数. 因为无限久之后炸弹爆炸的概率是1,所以最后在i点爆炸的概率实际上就是f[i]/sigma(f[]) 列出方程组 f[i ...

  4. bzoj1062【Noi2008】糖果雨

    orz.....神tm数形结合题 题意:http://www.lydsy.com/JudgeOnline/problem.php?id=1062 插入线段,删除线段,查询区间内线段个数,线段随时间往复 ...

  5. 四道JavaScript面试题检测你的js基本功

    下面有四道简短的JavaScript小脚本,如果你能顺利预测脚本的运行结果,那么你的JavaScript基本功还是可以的.如果答错了,可以相应地去补一下缺漏的知识.反正也很简单,答错了只是说明你没了解 ...

  6. 获取指定IP地址对应的物理位置

    # -*- coding: utf-8 -*- import requests def get_physical_location(ip): url = 'http://ip.taobao.com/s ...

  7. bzoj 2599 [IOI2011]Race 点分

    [IOI2011]Race Time Limit: 70 Sec  Memory Limit: 128 MBSubmit: 4768  Solved: 1393[Submit][Status][Dis ...

  8. Mac 访问隐藏文件方法! 网上方法在我电脑上都不可用!

    百度的方法: 如果你想打开整个系统的隐藏文件可以在终端下输入以下命令 defaults write com.apple.finder AppleShowAllFiles -bool true 关闭显示 ...

  9. UVA 808 Bee Breeding (坐标法)

    https://vjudge.net/problem/UVA-808 #include<cmath> #include<cstdio> #include<algorith ...

  10. aio 爬虫,去重,入库

    #aio 爬虫,去重,入库 import asyncio import aiohttp import aiomysql import re from pyquery import PyQuery st ...