下面是最基本的框架,内容和样式你需要自己调整
<!DOCTYPE html><html>
<head>
<meta charset="gb2312" />
<title></title>
<style type="text/css">
#tree {
width: 150px
}
#tree, #tree ul {
list-style: nonemargin: 0padding: 0padding: 10px
}
#tree li {
border: 1px solid #00fpadding: 10pxcursor: pointer
}
#tree ul {
display: none
}
</style>
<script type="text/javascript">
window.onload = function() {
var tree = document.getElementById("tree")
var lis = tree.getElementsByTagName("li")
for(var i = 0i <lis.lengthi++) {
(function(a) {
lis[a].onclick = function() {
if(typeof this.getElementsByTagName("ul") !== null) {
var ul_first = this.getElementsByTagName("ul")[0]
if(ul_first.style.display == "block")
ul_first.style.display = "none"
else
ul_first.style.display = "block"
}
}
})(i)
}
}
</script>
</head>
<body>
<ul id="tree">
<li>菜单一
<ul>
<li>1-1</li><li>1-2</li><li>1-3</li><li>1-4</li>
</ul>
</li>
<li>菜单二
<ul>
<li>2-1</li><li>2-2</li><li>2-3</li><li>2-4</li>
</ul>
</li>
<li>菜单三
<ul>
<li>3-1</li><li>3-2</li><li>3-3</li><li>3-4</li>
</ul>
</li>
</ul>
</body>
</html>
在HTML中Title是属于文档的一个对象,要想的到html的title可以用javascript脚本语言来实现。
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>知道用效果展示</title>
</head>
<body>
<script>
var tit=document.title
alert(tit)
</script>
</body>
</html>
以上例子就是将html的标题存入了tit变量,然后进行了一个弹窗显示。
没找准定位基准吧。selenium使用Xpath定位之完整篇
主题 Xpath Selenium
其中有一片文章提到了xpath元素定位,但是该文章中有些并不能适应一些特殊与个性化的场景。在文本中提供xpath元素的定位终极篇,你一定能在这里找到你需要的解决办法。
第一种方法:通过绝对路径做定位(相信大家不会使用这种方式)
By.xpath("html/body/div/form/input")
By.xpath("//input")
第三种方法:通过元素索引定位
By.xpath("//input[4]")
第四种方法:使用xpath属性定位(结合第2、第3中方法可以使用)
By.xpath("//input[@id='kw1']")
By.xpath("//input[@type='name' and @name='kw1']")
第五种方法:使用部分属性值匹配(最强大的方法)
By.xpath("//input[start-with(@id,'nice')
By.xpath("//input[ends-with(@id,'很漂亮')
By.xpath("//input[contains(@id,'那么美')]")
第6种方法:使用xpath轴(未曾使用)
希望,以上这些方法,能够帮助到你。