1通过selenium定位方式(id、name、xpath等方式)定位table标签
#html源码<table border="5" id="table1" width="80%">#selenium *** 作代码table1=driverfind_element_by_id('table1')
2获取总行数(也就是获取tr标签的个数)
#html源码<tr><th>姓名</th><th>性别</th></tr>#selenium *** 作源码
table_rows = table1find_elements_by_tag_name('tr')
3获取总列数(也就是tr标签下面的th标签个数)
#html源码<tr><th>姓名</th><th>性别</th></tr>#selenium *** 作源码:第一个tr标签下有多少个th
table_rows = table_rows[0]find_elements_by_tag_name('th')
4获取单个cell值
#selenium *** 作源码:第一行第二列的text值row1_col2 = table_rows[1]find_elements_by_tag_name('td')[1]text
5取值比对~
给表格tr绑定点击事件即可,详细代码如下:
$('#table3 tr')on('click', function(){
$(this)css('background-color','lightblue')
})
这是获得每个tr 中td 的内容
<script>
$('#myTableProduct tr')each(function(index,ele){
$(this)find('td')each(function(index,ele){
alert($(ele)html());
})
})
</script>
不用谢我
------君少
以上就是关于robotframework如何获取到网页<tr>元素中的title内的文字全部的内容,包括:robotframework如何获取到网页<tr>元素中的title内的文字、jquery 怎么得到当前tr在当前table中的位置、html JS 获取tr/td 表单元素下面的各个值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)