您的位置:首页 > Web前端 > CSS

7. 获取对象的熟悉以及CSS熟悉

2014-07-23 10:23 267 查看
HTML:
<html>
<head>
<metahttp-equiv="content-type"content="text/html;charset=utf-8"/>
<title>attribute</title>
<scripttype="text/javascript"async=""src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<linkhref="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css"rel="stylesheet"/>
<scripttype="text/javascript">
$(document).ready(function(){
$('#tooltip').tooltip({"placement":"right"});
});
</script>
</head>

<body>
<h3>attribute</h3>
<divclass="row-fluid">
<divclass="span6">
<aid="tooltip"href="#"data-toggle="tooltip"title="watir-webdriverbetterthanselenium-webdriver">hovertoseetooltip</a>
</div>
</div>
</body>
<scriptsrc="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
</html>

====================================================================================================================================================
PythonCode

#-*-coding:utf-8-*-
fromseleniumimportwebdriver
fromtimeimportsleep
importos
if'HTTP_PROXY'inos.environ:delos.environ['HTTP_PROXY']

dr=webdriver.Chrome()
file_path='file:///'+os.path.abspath('css.html')

dr.get(file_path)

link=dr.find_element_by_id('tooltip')
printlink.value_of_css_property('color')

printdr.find_element_by_tag_name('h3').value_of_css_property('font')

#获得tooltip的内容
printlink.get_attribute('title')

#获取该链接的text
printlink.text

dr.quit()


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: