| 132 | |
| 133 | |
| 134 | class DataTableCellFacade(object): |
| 135 | @preconditions( |
| 136 | _validate_id, _validate_mixin, _validate_row, _validate_col, _validate_state |
| 137 | ) |
| 138 | def __init__(self, id, mixin, row, col, state=_ANY): |
| 139 | self.id = id |
| 140 | self.mixin = mixin |
| 141 | self.row = row |
| 142 | self.col = col |
| 143 | self.state = state |
| 144 | |
| 145 | def _get_cell_value(self): |
| 146 | return self.get().find_element(By.CSS_SELECTOR, ".dash-cell-value") |
| 147 | |
| 148 | def click(self): |
| 149 | return self.get().click() |
| 150 | |
| 151 | def double_click(self): |
| 152 | ac = ActionChains(self.mixin.driver) |
| 153 | ac.move_to_element(self._get_cell_value()) |
| 154 | ac.pause(1) # sometimes experiencing incorrect behavior on scroll otherwise |
| 155 | ac.double_click() |
| 156 | return ac.perform() |
| 157 | |
| 158 | def exists(self): |
| 159 | self.mixin._wait_for_table(self.id, self.state) |
| 160 | |
| 161 | return ( |
| 162 | len( |
| 163 | self.mixin.find_elements( |
| 164 | '#{} {} tbody td.dash-cell.column-{}[data-dash-row="{}"]:not(.phantom-cell)'.format( |
| 165 | self.id, self.state, self.col, self.row |
| 166 | ) |
| 167 | ) |
| 168 | ) |
| 169 | == 1 |
| 170 | if isinstance(self.col, int) |
| 171 | else len( |
| 172 | self.mixin.find_elements( |
| 173 | '#{} {} tbody td.dash-cell[data-dash-column="{}"][data-dash-row="{}"]:not(.phantom-cell)'.format( |
| 174 | self.id, self.state, self.col, self.row |
| 175 | ) |
| 176 | ) |
| 177 | ) |
| 178 | == 1 |
| 179 | ) |
| 180 | |
| 181 | def get(self): |
| 182 | self.mixin._wait_for_table(self.id, self.state) |
| 183 | |
| 184 | return ( |
| 185 | self.mixin.find_element( |
| 186 | '#{} {} tbody td.dash-cell.column-{}[data-dash-row="{}"]:not(.phantom-cell)'.format( |
| 187 | self.id, self.state, self.col, self.row |
| 188 | ) |
| 189 | ) |
| 190 | if isinstance(self.col, int) |
| 191 | else self.mixin.find_element( |