Skip to content

Commit

Permalink
[#505] REFACTOR: postpone All descriptor filtering :( + ...
Browse files Browse the repository at this point in the history
[#530] NEW: match.checked
  • Loading branch information
yashaka committed Jul 21, 2024
1 parent 05a0bed commit 9f73818
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions selene/core/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ def native_property(name: str, _inverted=False):
)


# todo: should we make it smarter enough to handle mobile element context?
checked: Condition[Element] = native_property('checked').value(True)


def css_property(name: str, _inverted=False):
return _ElementDescriptor(
name,
Expand Down
2 changes: 2 additions & 0 deletions selene/support/conditions/be.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
enabled = match.enabled
disabled = match.disabled

checked = match.checked

clickable = match.clickable

blank = match.blank
Expand Down
3 changes: 3 additions & 0 deletions selene/support/conditions/not_.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def property_(name: str, *args, **kwargs):
return _match.native_property(name, _inverted=True)


checked = _match.checked.not_


def css_property(name: str, *args, **kwargs):
if args or 'value' in kwargs:
warnings.warn(
Expand Down
19 changes: 18 additions & 1 deletion tests/examples/pom/test_material_ui__react_x_data_grid__mit.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import pytest

from selene import browser, have
from selene import browser, have, be
from selene.support._pom import Element, All


class DataGridMIT:
grid = Element('[role=grid]')
headers = grid.All('[role=columnheader]')
header = grid.Element('.MuiDataGrid-columnHeaders')
toggle_all_checkbox = header.Element('.PrivateSwitchBase-input')
'''
# todo: support also the following:
toggle_all = headers.ElementBy(have.attribute('data-field').value('__check__'))
toggle_all_checkbox = toggle_all.Element('[type=checkbox]')
'''

footer = Element('.MuiDataGrid-footerContainer')
selected_rows_count = footer.Element('.MuiDataGrid-selectedRowCount')
pagination = footer.Element('.MuiTablePagination-root')
pagination_rows_displayed = pagination.Element('.MuiTablePagination-displayedRows')
page_to_right = pagination.Element('[data-testid=KeyboardArrowRightIcon]')
Expand Down Expand Up @@ -43,3 +51,12 @@ def test_material_ui__react_x_data_grid_mit(characters):
characters.pagination_rows_displayed.should(have.exact_text('6–9 of 9'))
characters.page_to_left.click()
characters.pagination_rows_displayed.should(have.exact_text('1–5 of 9'))

characters.selected_rows_count.should(be.not_.visible)
characters.toggle_all_checkbox.should(be.not_.checked)
characters.toggle_all_checkbox.click()
characters.toggle_all_checkbox.should(be.checked)
characters.selected_rows_count.should(have.exact_text('9 rows selected'))
characters.toggle_all_checkbox.click()
characters.toggle_all_checkbox.should(be.not_.checked)
characters.selected_rows_count.should(be.not_.visible)

0 comments on commit 9f73818

Please sign in to comment.