一、直接获取整个表格数据,包含表头

 

selenium+python对表格数据的操作

2、如果不要表头,可直接用定位tbody元素,同样的方法获取到表格数据,不包含表头

3、输入关键字,搜索表格数据,验证搜索功能

此时直接用第一种方法,会提示错误。因为点击查询的时候,tbody数据重新加载,不依附于原页面

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

没有和当前页面进行绑定,主要是页面刷新或者跳转引起的,需要重新获取一次元素。

此时需要重新定位tbody元素,再次查询

 

selenium+python对表格数据的操作

相关文章:

  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案