Skip to content

Commit ce116e7

Browse files
committed
updating table util
1 parent 78c35cc commit ce116e7

File tree

1 file changed

+181
-10
lines changed

1 file changed

+181
-10
lines changed

docs/utility-guides/TableUtil.md

Lines changed: 181 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,39 @@ The Table Utilities module provides helper functions to interact with and valida
66

77
- [Utility Guide: Table Utility](#utility-guide-table-utility)
88
- [Table of Contents](#table-of-contents)
9-
- [Functions Overview](#functions-overview)
109
- [Get Column Index](#get-column-index)
1110
- [Required Arguments](#required-arguments)
1211
- [How This Function Works](#how-this-function-works)
13-
14-
## Functions Overview
15-
16-
For this utility we have the following functions:
17-
18-
- `get_column_index`
19-
- `click_first_link_in_column`
20-
- `click_first_input_in_column`
12+
- [Click first link in Column](#click-first-link-in-column)
13+
- [Required Arguments](#required-arguments-1)
14+
- [How This Function Works](#how-this-function-works-1)
15+
- [Click first input in Column](#click-first-input-in-column)
16+
- [Required Arguments](#required-arguments-2)
17+
- [How This Function Works](#how-this-function-works-2)
18+
- [\_format\_inner\_text](#_format_inner_text)
19+
- [Required Arguments](#required-arguments-3)
20+
- [How This Function Works](#how-this-function-works-3)
21+
- [get\_table\_headers](#get_table_headers)
22+
- [Required Arguments](#required-arguments-4)
23+
- [How This Function Works](#how-this-function-works-4)
24+
- [get\_row\_count](#get_row_count)
25+
- [Required Arguments](#required-arguments-5)
26+
- [How This Function Works](#how-this-function-works-5)
27+
- [pick\_row](#pick_row)
28+
- [Required Arguments](#required-arguments-6)
29+
- [How This Function Works](#how-this-function-works-6)
30+
- [pick\_random\_row](#pick_random_row)
31+
- [Required Arguments](#required-arguments-7)
32+
- [How This Function Works](#how-this-function-works-7)
33+
- [pick\_random\_row\_number](#pick_random_row_number)
34+
- [Required Arguments](#required-arguments-8)
35+
- [How This Function Works](#how-this-function-works-8)
36+
- [get\_row\_data\_with\_headers](#get_row_data_with_headers)
37+
- [Required Arguments](#required-arguments-9)
38+
- [How This Function Works](#how-this-function-works-9)
39+
- [get\_full\_table\_with\_headers](#get_full_table_with_headers)
40+
- [Required Arguments](#required-arguments-10)
41+
- [How This Function Works](#how-this-function-works-10)
2142

2243
### Get Column Index
2344

@@ -32,5 +53,155 @@ This function returns the index (1-based) of a specified column name.
3253
#### How This Function Works
3354

3455
1. Attempts to identify table headers from <thead> or <tbody>.
35-
2. Iterates through header cells and matches text with column_name.
56+
2. Iterates through header cells and matches text with `column_name`.
3657
3. Returns the index if found, otherwise raises an error.
58+
59+
### Click first link in Column
60+
61+
Clicks on the first hyperlink present in a specified column.
62+
63+
#### Required Arguments
64+
65+
-`column_name`:
66+
-Type: `str`
67+
-The column in which the link needs to be found.
68+
69+
#### How This Function Works
70+
71+
1. Finds the index of the specified column.
72+
2. Searches the first visible row in the column for an <a> tag.
73+
3. Clicks the first available link found.
74+
75+
### Click first input in Column
76+
77+
Clicks on the first input element (e.g., checkbox/radio) in a specific column.
78+
79+
#### Required Arguments
80+
81+
-`column_name`:
82+
-Type: `str`
83+
-The name of the column containing the input element.
84+
85+
#### How This Function Works
86+
87+
1. Locates the index of the specified column.
88+
2. Checks the first visible row for an <input> tag in that column.
89+
3. Clicks the first input found.
90+
91+
### _format_inner_text
92+
93+
Formats inner text of a row string into a dictionary.
94+
95+
#### Required Arguments
96+
97+
-data:
98+
-Type: `str`
99+
-Raw inner text of a table row (tab-delimited).
100+
101+
#### How This Function Works
102+
103+
1. Splits the string by tab characters (\t).
104+
2. Enumerates the result and maps index to cell value.
105+
3. Returns a dictionary representing the row.
106+
107+
### get_table_headers
108+
109+
Extracts and returns table headers.
110+
111+
#### Required Arguments
112+
113+
-None
114+
115+
#### How This Function Works
116+
117+
1. Selects the first row inside <thead> (if available).
118+
2. Captures the visible text of each <th>.
119+
3. Returns a dictionary mapping index to header text.
120+
121+
### get_row_count
122+
123+
Returns the count of visible rows in the table.
124+
125+
#### Required Arguments
126+
127+
-None
128+
129+
#### How This Function Works
130+
131+
1. Locates all <tr> elements inside <tbody>.
132+
2. Filters to include only visible rows.
133+
3. Returns the total count.
134+
135+
### pick_row
136+
137+
Returns a locator for a specific row.
138+
139+
#### Required Arguments
140+
141+
-`row_number`:
142+
-Type: `int`
143+
-The row index to locate (1-based).
144+
145+
#### How This Function Works
146+
147+
1. Builds a locator for the nth <tr> inside <tbody>.
148+
2. Returns the locator object.
149+
150+
### pick_random_row
151+
152+
Picks and returns a random row locator.
153+
154+
#### Required Arguments
155+
156+
None
157+
158+
#### How This Function Works
159+
160+
1. Gets all visible rows inside <tbody>.
161+
2. Uses a secure random generator to pick one.
162+
3. Returns the locator for that row.
163+
164+
### pick_random_row_number
165+
166+
Returns the number of a randomly selected row.
167+
168+
#### Required Arguments
169+
170+
None
171+
172+
#### How This Function Works
173+
174+
1. Retrieves visible rows from <tbody>.
175+
2. Randomly selects an index using secrets.choice.
176+
3. Returns the numeric index.
177+
178+
### get_row_data_with_headers
179+
180+
Returns a dictionary of header-value pairs for a given row.
181+
182+
#### Required Arguments
183+
184+
-`row_number`:
185+
-Type:int
186+
-Index of the target row (1-based).
187+
188+
#### How This Function Works
189+
190+
1. Extracts text from the specified row.
191+
2. Retrieves headers using get_table_headers.
192+
3. Maps each cell to its respective header.
193+
194+
### get_full_table_with_headers
195+
196+
Constructs a dictionary of the entire table content.
197+
198+
#### Required Arguments
199+
200+
-None
201+
202+
#### How This Function Works
203+
204+
1. Gets all visible rows.
205+
2. Retrieves headers once.
206+
3. Loops over each row and builds a dictionary using get_row_data_with_headers.
207+
4. Returns a dictionary where each key is a row number.

0 commit comments

Comments
 (0)