当前位置:首页>开发>正文

列表用selenium怎么定位 selenium怎么定位这个按钮,求高手解决下。

2023-04-18 23:34:00 互联网 未知 开发

 列表用selenium怎么定位 selenium怎么定位这个按钮,求高手解决下。

列表用selenium怎么定位

有两种方式:
常规的定位.比如xpath: //table//tr[2]/td[3] 或者 css=table tr:eq(1) td:eq(2)
直接通过tableCellAddress, 语法为: tableLocator.row.column比如: table id 为 foo: 则第2行第5列可以使用 foo.1.4 来定位.

下面是selenium关于table的相关文档
Generated from getTable(tableCellAddress)Arguments:tableCellAddress - a cell address, e.g. "foo.1.4"Returns:the text from the specified cellGets the text from a cell of a table. The cellAddress syntax tableLocator.row.column, where row and column start at 0.

selenium怎么定位这个按钮,求高手解决下。

使用linkText定位方式试试看呢
WebElement find_by_LinkText = driver.findElement(By.linkText("Append"))
使用这个定位方法的话,注意页面中连接的文本不能有重复的,例如你上面代码的Append

selenium css选择器怎么定位

1. 结构性定位就是根据元素的父子、同级中位置来定位,css3标准中有定义一些结构性定位伪类如nth-of-type,nth-child,但是使用起来语法很不好理解,这里就不做介绍了。
2. Selenium中则是采用了来自Sizzle的css3定位扩展,它的语法更加灵活易懂
3. Sizzle Css3的结构性定位语法  !

最新文章