| 253 | |
| 254 | |
| 255 | class DataTableColumnFacade(object): |
| 256 | @preconditions(_validate_id, _validate_mixin, _validate_col, _validate_state) |
| 257 | def __init__(self, id, mixin, col, state=_ANY): |
| 258 | self.id = id |
| 259 | self.mixin = mixin |
| 260 | self.col = col |
| 261 | self.state = state |
| 262 | |
| 263 | @preconditions(_validate_row) |
| 264 | def get(self, row=0): |
| 265 | self.mixin._wait_for_table(self.id, self.state) |
| 266 | |
| 267 | return ( |
| 268 | self.mixin.find_element( |
| 269 | "#{} {} tbody tr:nth-of-type({}) th.dash-header.column-{}:not(.phantom-cell)".format( |
| 270 | self.id, self.state, row + 1, self.col |
| 271 | ) |
| 272 | ) |
| 273 | if isinstance(self.col, int) |
| 274 | else self.mixin.find_element( |
| 275 | '#{} {} tbody tr:nth-of-type({}) th.dash-header[data-dash-column="{}"]:not(.phantom-cell)'.format( |
| 276 | self.id, self.state, row + 1, self.col |
| 277 | ) |
| 278 | ) |
| 279 | ) |
| 280 | |
| 281 | def find_inside(self, row, selector): |
| 282 | return self.get(row).find_element(By.CSS_SELECTOR, selector) |
| 283 | |
| 284 | def find_all_inside(self, row, selector): |
| 285 | return self.get(row).find_elements(By.CSS_SELECTOR, selector) |
| 286 | |
| 287 | def exists(self, row=0): |
| 288 | self.mixin._wait_for_table(self.id, self.state) |
| 289 | |
| 290 | els = ( |
| 291 | self.mixin.find_elements( |
| 292 | "#{} {} tbody tr:nth-of-type({}) th.dash-header.column-{}:not(.phantom-cell)".format( |
| 293 | self.id, self.state, row + 1, self.col |
| 294 | ) |
| 295 | ) |
| 296 | if isinstance(self.col, int) |
| 297 | else self.mixin.find_elements( |
| 298 | '#{} {} tbody tr:nth-of-type({}) th.dash-header[data-dash-column="{}"]:not(.phantom-cell)'.format( |
| 299 | self.id, self.state, row + 1, self.col |
| 300 | ) |
| 301 | ) |
| 302 | ) |
| 303 | |
| 304 | return len(els) != 0 |
| 305 | |
| 306 | @preconditions(_validate_row) |
| 307 | def clear(self, row=0): |
| 308 | self.find_inside(row, ".column-header--clear").click() |
| 309 | |
| 310 | @preconditions(_validate_row) |
| 311 | def delete(self, row=0): |
| 312 | self.find_inside(row, ".column-header--delete").click() |