@@ -1174,14 +1174,14 @@ def expect_page_mode(self, value: str, *, timeout: Timeout = None):
1174
1174
)
1175
1175
return self
1176
1176
1177
- def expect_wc_attribute (self , value : str , * , timeout : Timeout = None ):
1177
+ def expect_attribute (self , value : str , * , timeout : Timeout = None ):
1178
1178
"""
1179
- Expect the `wc` attribute of the input dark mode to have a specific value.
1179
+ Expect the attribute named ` attribute` of the input dark mode to have a specific value.
1180
1180
1181
1181
Parameters
1182
1182
----------
1183
1183
value
1184
- The expected value of the `wc ` attribute.
1184
+ The expected value of the `attribute ` attribute.
1185
1185
timeout
1186
1186
The maximum time to wait for the expectation to be fulfilled. Defaults to `None`.
1187
1187
"""
@@ -1398,7 +1398,8 @@ def set(self, value: bool, *, timeout: Timeout = None, **kwargs: object) -> None
1398
1398
value , timeout = timeout , ** kwargs # pyright: ignore[reportArgumentType]
1399
1399
)
1400
1400
1401
- def toggle (self , * , timeout : Timeout = None , ** kwargs : object ) -> None :
1401
+ # TODO-karan-test: Convert usage of _toggle() to set()
1402
+ def _toggle (self , * , timeout : Timeout = None , ** kwargs : object ) -> None :
1402
1403
"""
1403
1404
Toggles the input checkbox.
1404
1405
@@ -1480,6 +1481,7 @@ def __init__(
1480
1481
)
1481
1482
1482
1483
1484
+ # TODO-future: Move class methods to a separate module
1483
1485
class _MultipleDomItems :
1484
1486
@staticmethod
1485
1487
def assert_arr_is_unique (
@@ -1811,7 +1813,7 @@ def __init__(
1811
1813
1812
1814
def set (
1813
1815
self ,
1814
- # Allow `selected` to be a single Pattern to perform matching against many items
1816
+ # TODO-future: Allow `selected` to be a single Pattern to perform matching against many items
1815
1817
selected : list [str ],
1816
1818
* ,
1817
1819
timeout : Timeout = None ,
@@ -2072,19 +2074,6 @@ class InputFile(
2072
2074
Playwright `Locator` of the progress bar.
2073
2075
"""
2074
2076
2075
- # id: str,
2076
- # label: TagChild,
2077
- # *,
2078
- # multiple: bool = False,
2079
- # accept: Optional[Union[str, list[str]]] = None,
2080
- # width: Optional[str] = None,
2081
- # button_label: str = "Browse...",
2082
- # placeholder: str = "No file selected",
2083
- # capture: Optional[Literal["environment", "user"]] = None,
2084
- # with page.expect_file_chooser() as fc_info:
2085
- # page.get_by_text("Upload").click()
2086
- # file_chooser = fc_info.value
2087
- # file_chooser.set_files("myfile.pdf")
2088
2077
def __init__ (
2089
2078
self ,
2090
2079
page : Page ,
@@ -3697,7 +3686,12 @@ class _OutputImageBase(_OutputInlineContainerM, _OutputBase):
3697
3686
Playwright `Locator` of the image.
3698
3687
"""
3699
3688
3700
- def __init__ (self , page : Page , id : str , loc_classes : str = "" ) -> None :
3689
+ def __init__ (
3690
+ self ,
3691
+ page : Page ,
3692
+ id : str ,
3693
+ loc_classes : str = "" ,
3694
+ ) -> None :
3701
3695
"""
3702
3696
Initializes an image output.
3703
3697
@@ -3904,20 +3898,6 @@ def expect_empty(self, value: bool, *, timeout: Timeout = None) -> None:
3904
3898
else :
3905
3899
self .expect .not_to_be_empty (timeout = timeout )
3906
3900
3907
- def expect_text (self , value : str , * , timeout : Timeout = None ) -> None :
3908
- """
3909
- Asserts that the output has the expected text.
3910
-
3911
- Parameters
3912
- ----------
3913
- value
3914
- The expected text.
3915
- timeout
3916
- The maximum time to wait for the text to appear. Defaults to `None`.
3917
- """
3918
-
3919
- self .expect .to_have_text (value , timeout = timeout )
3920
-
3921
3901
3922
3902
# When making selectors, use `xpath` so that direct decendents can be checked
3923
3903
class OutputTable (_OutputBase ):
@@ -4022,7 +4002,7 @@ def expect_column_text(
4022
4002
timeout = timeout ,
4023
4003
)
4024
4004
4025
- def expect_n_col (
4005
+ def expect_ncol (
4026
4006
self ,
4027
4007
value : int ,
4028
4008
* ,
@@ -4046,7 +4026,7 @@ def expect_n_col(
4046
4026
timeout = timeout ,
4047
4027
)
4048
4028
4049
- def expect_n_row (
4029
+ def expect_nrow (
4050
4030
self ,
4051
4031
value : int ,
4052
4032
* ,
@@ -4188,9 +4168,9 @@ def set(self, open: bool, *, timeout: Timeout = None) -> None:
4188
4168
The maximum time to wait for the sidebar to open or close. Defaults to `None`.
4189
4169
"""
4190
4170
if open ^ (self .loc_handle .get_attribute ("aria-expanded" ) == "true" ):
4191
- self .toggle (timeout = timeout )
4171
+ self ._toggle (timeout = timeout )
4192
4172
4193
- def toggle (self , * , timeout : Timeout = None ) -> None :
4173
+ def _toggle (self , * , timeout : Timeout = None ) -> None :
4194
4174
"""
4195
4175
Toggles the sidebar open or closed.
4196
4176
@@ -4782,7 +4762,7 @@ def expect_panels(
4782
4762
4783
4763
def set (
4784
4764
self ,
4785
- selected : str | list [str ],
4765
+ open : str | list [str ],
4786
4766
* ,
4787
4767
timeout : Timeout = None ,
4788
4768
) -> None :
@@ -4791,13 +4771,13 @@ def set(
4791
4771
4792
4772
Parameters
4793
4773
----------
4794
- selected
4795
- The selected accordion panel(s).
4774
+ open
4775
+ The open accordion panel(s).
4796
4776
timeout
4797
4777
The maximum time to wait for the accordion panel to be visible and interactable. Defaults to `None`.
4798
4778
"""
4799
- if isinstance (selected , str ):
4800
- selected = [selected ]
4779
+ if isinstance (open , str ):
4780
+ open = [open ]
4801
4781
for element in self .loc .element_handles ():
4802
4782
element .wait_for_element_state (state = "visible" , timeout = timeout )
4803
4783
element .scroll_into_view_if_needed (timeout = timeout )
@@ -4806,9 +4786,7 @@ def set(
4806
4786
raise ValueError (
4807
4787
"Accordion panel does not have a `data-value` attribute"
4808
4788
)
4809
- self .accordion_panel (elem_value ).set (
4810
- elem_value in selected , timeout = timeout
4811
- )
4789
+ self .accordion_panel (elem_value ).set (elem_value in open , timeout = timeout )
4812
4790
4813
4791
def accordion_panel (
4814
4792
self ,
@@ -4955,9 +4933,9 @@ def set(self, open: bool, *, timeout: Timeout = None) -> None:
4955
4933
self .loc .scroll_into_view_if_needed (timeout = timeout )
4956
4934
expect_not_to_have_class (self .loc_body , "collapsing" , timeout = timeout )
4957
4935
if self ._loc_body_visible .count () != int (open ):
4958
- self .toggle (timeout = timeout )
4936
+ self ._toggle (timeout = timeout )
4959
4937
4960
- def toggle (self , * , timeout : Timeout = None ) -> None :
4938
+ def _toggle (self , * , timeout : Timeout = None ) -> None :
4961
4939
"""
4962
4940
Toggles the state of the control.
4963
4941
@@ -5156,9 +5134,9 @@ def set(self, open: bool, timeout: Timeout = None) -> None:
5156
5134
The maximum time to wait for the popover to be visible and interactable. Defaults to `None`.
5157
5135
"""
5158
5136
if open ^ self .get_loc_overlay_body (timeout = timeout ).count () > 0 :
5159
- self .toggle ()
5137
+ self ._toggle ()
5160
5138
5161
- def toggle (self , timeout : Timeout = None ) -> None :
5139
+ def _toggle (self , timeout : Timeout = None ) -> None :
5162
5140
"""
5163
5141
Toggles the state of the popover.
5164
5142
@@ -5227,11 +5205,11 @@ def set(self, open: bool, timeout: Timeout = None) -> None:
5227
5205
The maximum time to wait for the tooltip to be visible and interactable. Defaults to `None`.
5228
5206
"""
5229
5207
if open ^ self .get_loc_overlay_body (timeout = timeout ).count () > 0 :
5230
- self .toggle (timeout = timeout )
5208
+ self ._toggle (timeout = timeout )
5231
5209
if not open :
5232
5210
self .get_loc_overlay_body (timeout = timeout ).click ()
5233
5211
5234
- def toggle (self , timeout : Timeout = None ) -> None :
5212
+ def _toggle (self , timeout : Timeout = None ) -> None :
5235
5213
"""
5236
5214
Toggles the state of the tooltip.
5237
5215
@@ -5304,7 +5282,9 @@ def get_loc_active_content(self, *, timeout: Timeout = None) -> Locator:
5304
5282
f"div.tab-content[data-tabsetid='{ datatab_id } '] > div.tab-pane.active"
5305
5283
)
5306
5284
5307
- def expect_content (self , value : PatternOrStr , * , timeout : Timeout = None ) -> None :
5285
+ def _expect_content_text (
5286
+ self , value : PatternOrStr , * , timeout : Timeout = None
5287
+ ) -> None :
5308
5288
"""
5309
5289
Expects the control to have the specified content.
5310
5290
@@ -5439,7 +5419,9 @@ def expect_active(self, value: bool, *, timeout: Timeout = None) -> None:
5439
5419
"""
5440
5420
_expect_class_value (self .loc , "active" , value , timeout = timeout )
5441
5421
5442
- def expect_content (self , value : PatternOrStr , * , timeout : Timeout = None ) -> None :
5422
+ def _expect_content_text (
5423
+ self , value : PatternOrStr , * , timeout : Timeout = None
5424
+ ) -> None :
5443
5425
"""
5444
5426
Expects the nav item content to have the specified text.
5445
5427
@@ -5876,7 +5858,7 @@ def cell_locator(self, row: int, col: int) -> Locator:
5876
5858
)
5877
5859
5878
5860
# TODO-barret; Should this be called `expect_row_count()`?
5879
- def expect_n_row (self , value : int , * , timeout : Timeout = None ):
5861
+ def expect_nrow (self , value : int , * , timeout : Timeout = None ):
5880
5862
"""
5881
5863
Expects the number of rows in the data frame.
5882
5864
@@ -5891,7 +5873,7 @@ def expect_n_row(self, value: int, *, timeout: Timeout = None):
5891
5873
value , timeout = timeout
5892
5874
)
5893
5875
5894
- def expect_selected_n_row (self , value : int , * , timeout : Timeout = None ):
5876
+ def expect_selected_num_rows (self , value : int , * , timeout : Timeout = None ):
5895
5877
"""
5896
5878
Expects the number of selected rows in the data frame.
5897
5879
@@ -5953,7 +5935,7 @@ def expect_selected_rows(self, rows: list[int], *, timeout: Timeout = None):
5953
5935
# Could not find the reason why. Raising the original error.
5954
5936
raise e
5955
5937
5956
- def expect_row_focus_state (
5938
+ def _expect_row_focus_state (
5957
5939
self , in_focus : bool = True , * , row : int , timeout : Timeout = None
5958
5940
):
5959
5941
"""
@@ -6077,7 +6059,7 @@ def _cell_scroll_if_needed(self, *, row: int, col: int, timeout: Timeout):
6077
6059
break
6078
6060
cell .scroll_into_view_if_needed (timeout = timeout )
6079
6061
6080
- def expect_column_label (
6062
+ def _expect_column_label (
6081
6063
self ,
6082
6064
value : ListPatternOrStr ,
6083
6065
* ,
@@ -6103,7 +6085,7 @@ def expect_column_label(
6103
6085
timeout = timeout ,
6104
6086
)
6105
6087
6106
- def expect_n_col (
6088
+ def expect_ncol (
6107
6089
self ,
6108
6090
value : int ,
6109
6091
* ,
@@ -6231,7 +6213,7 @@ def expect_class_state(
6231
6213
"Invalid state. Select one of 'success', 'failure', 'saving', 'editing', 'ready'"
6232
6214
)
6233
6215
6234
- def edit_cell (
6216
+ def _edit_cell_no_save (
6235
6217
self ,
6236
6218
text : str ,
6237
6219
* ,
@@ -6421,13 +6403,15 @@ def set_filter(
6421
6403
"Invalid filter value. Must be a string or a tuple/list of two numbers."
6422
6404
)
6423
6405
6424
- def save_cell (
6406
+ def set_cell (
6425
6407
self ,
6426
6408
text : str ,
6427
6409
* ,
6428
6410
row : int ,
6429
6411
col : int ,
6430
- save_key : str ,
6412
+ finish_key : (
6413
+ Literal ["Enter" , "Shift+Enter" , "Tab" , "Shift+Tab" , "Escape" ] | None
6414
+ ) = None ,
6431
6415
timeout : Timeout = None ,
6432
6416
) -> None :
6433
6417
"""
@@ -6441,11 +6425,17 @@ def save_cell(
6441
6425
The row number of the cell.
6442
6426
col
6443
6427
The column number of the cell.
6428
+ finish_key
6429
+ The key to save the value of the cell. If `None` (the default), no key will
6430
+ be pressed and instead the page body will be clicked.
6444
6431
timeout
6445
6432
The maximum time to wait for the action to complete. Defaults to `None`.
6446
6433
"""
6447
- self .edit_cell (text , row = row , col = col , timeout = timeout )
6448
- self .cell_locator (row = row , col = col ).locator ("> textarea" ).press (save_key )
6434
+ self ._edit_cell_no_save (text , row = row , col = col , timeout = timeout )
6435
+ if finish_key is None :
6436
+ self .page .locator ("body" ).click ()
6437
+ else :
6438
+ self .cell_locator (row = row , col = col ).locator ("> textarea" ).press (finish_key )
6449
6439
6450
6440
def expect_cell_title (
6451
6441
self ,
@@ -6456,7 +6446,8 @@ def expect_cell_title(
6456
6446
timeout : Timeout = None ,
6457
6447
) -> None :
6458
6448
"""
6459
- Expects the validation message of the cell in the data frame.
6449
+ Expects the validation message of the cell in the data frame, which will be in
6450
+ the `title` attribute of the element.
6460
6451
6461
6452
Parameters
6462
6453
----------
0 commit comments