Elements with a given class in the DOM can be retrieved by class via the find method.
()
| 35 | |
| 36 | |
| 37 | def test_find_item_by_class(): |
| 38 | """ |
| 39 | Elements with a given class in the DOM can be retrieved by class via the |
| 40 | find method. |
| 41 | """ |
| 42 | ids = [ |
| 43 | "test_class_selector", |
| 44 | "test_selector_w_children", |
| 45 | "test_selector_w_children_child_1", |
| 46 | ] |
| 47 | expected_class = "a-test-class" |
| 48 | result = web.page.find(f".{expected_class}") |
| 49 | # EXPECT to find exact number of elements with the class in the page (== 3) |
| 50 | assert len(result) == 3 |
| 51 | # EXPECT that all element ids are in the expected list |
| 52 | assert [el.id for el in result] == ids |
| 53 | |
| 54 | |
| 55 | def test_read_n_write_collection_elements(): |