|
16 | 16 | from paf.assertion import StringAssertion, Format, BinaryAssertion, QuantityAssertion, RectAssertion |
17 | 17 | from paf.common import HasParent, Locator, Point, Rect, Property, Formatter |
18 | 18 | from paf.control import Control |
| 19 | +from paf.dom import Attribute |
19 | 20 | from paf.locator import By |
20 | 21 | from paf.types import Mapper, Consumer, R |
21 | 22 | from paf.xpath import XPath |
@@ -59,6 +60,10 @@ def type(self, value: str): |
59 | 60 | def clear(self): |
60 | 61 | pass |
61 | 62 |
|
| 63 | + @abstractmethod |
| 64 | + def submit(self): |
| 65 | + pass |
| 66 | + |
62 | 67 |
|
63 | 68 | T = TypeVar('T') |
64 | 69 |
|
@@ -284,6 +289,10 @@ def clear(self): |
284 | 289 | self._action_sequence(lambda web_element: web_element.clear()) |
285 | 290 | return self |
286 | 291 |
|
| 292 | + def submit(self): |
| 293 | + self._action_sequence(lambda web_element: web_element.submit()) |
| 294 | + return self |
| 295 | + |
287 | 296 | def __str__(self): |
288 | 297 | return self.name |
289 | 298 |
|
@@ -387,18 +396,24 @@ def _map(web_element: WebElement): |
387 | 396 |
|
388 | 397 | return self._map_web_element_property(StringAssertion, _map, "tag name") |
389 | 398 |
|
390 | | - def attribute(self, attribute: str): |
| 399 | + def attribute(self, attribute: str|Attribute): |
| 400 | + if isinstance(attribute, Attribute): |
| 401 | + attribute = attribute.value |
| 402 | + |
391 | 403 | def _map(web_element: WebElement): |
392 | 404 | return web_element.get_attribute(attribute) |
393 | 405 |
|
394 | | - return self._map_web_element_property(StringAssertion, _map, f"attribute({attribute}") |
| 406 | + return self._map_web_element_property(StringAssertion, _map, f"attribute({attribute})") |
395 | 407 |
|
396 | 408 | def css(self, property_name: str): |
397 | 409 | def _map(web_element: WebElement): |
398 | 410 | return web_element.value_of_css_property(property_name) |
399 | 411 |
|
400 | 412 | return self._map_web_element_property(StringAssertion, _map, f"css({property_name}") |
401 | 413 |
|
| 414 | + def classes(self, *classes): |
| 415 | + return self.attribute(Attribute.CLASS).has_words(*classes) |
| 416 | + |
402 | 417 | @property |
403 | 418 | def visible(self): |
404 | 419 | return self._visible(False) |
|
0 commit comments