From 71a745e3771fc5ea836cd0e3a43d75acf8d91951 Mon Sep 17 00:00:00 2001 From: Pavel Novotny Date: Wed, 17 Jul 2024 15:49:47 +0200 Subject: [PATCH] hosts: new widget for Hosts table (#1465) The `SatTable` widget is modified to ignore hidden headers and columns in the table. Hidden duplicate columns cause the widget to work incorrectly internally, while on the outside everything seems in order. This behavior is especially present in the Hosts table, where instead of seemingly interacting with the visible columns, the widget interacts with the hidden ones. The table widget for Hosts somehow worked properly(-ish), until commit 886a1a80debec16169ed56b6424e7238072df05e exposed this flaw. Excluding the hidden columns during the table cells collection by the widget solves the problem. --- airgun/widgets.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/airgun/widgets.py b/airgun/widgets.py index 76e06a4c6..3a9f05205 100644 --- a/airgun/widgets.py +++ b/airgun/widgets.py @@ -1881,6 +1881,8 @@ class SatTable(Table): If the table is empty, there might be only one column with an appropriate message in the table body, or it may have no columns or rows at all. This subclass handles both possibilities. + It also ignores all hidden columns, which some tables might contain, like the Hosts table. + Example html representation:: @@ -1907,6 +1909,10 @@ class SatTable(Table): """ + HEADERS = "./thead/tr/th[not(@hidden)]|./tr/th[not(@hidden)]|./thead/tr/td[not(@hidden)]" + COLUMN_RESOLVER_PATH = "/td[not(@hidden)]" + COLUMN_AT_POSITION = "./td[not(@hidden)][{0}]" + no_rows_message = ( ".//td/span[contains(@data-block, 'no-rows-message') or " "contains(@data-block, 'no-search-results-message')]"