hjwp / hjwp/Book-TDD-Web-Dev-Python
ch11l032 - Typo in the test / issue with wait_for + truthiness
- Ngôn ngữ chính
- Python
- Star
- 514
- Fork
- 175
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
In `ch11l032`, this is introduced, to test the HTML5 validation:
```python
self.wait_for(lambda: self.browser.find_elements_by_css_selector(
'#id_text:invalid'
))
```
However, it isn't testing anything.
Because we are using `find_elementS_by_css_selector(...)` if the element is not found an empty list will be returned and no exception will be raised. Therefore our `wait_for` immediately returns after the first try and we didn't test anything (try making it fail on purpose by looking for a different id, it won't fail).
To fix that, the solution is simple, remove the `S`. That way it'll either find that one element, or raise a `NoSuchElementException`, which is a `WebDriverException`, so our `wait_for` works as expected 🙂
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Find ch11l032 in the chapter's tests and inspect the wait_for call that uses find_elements_by_css_selector. Change the selector lookup to the singular form, then run the relevant ch11l032 test and verify that a missing invalid element causes the wait to fail rather than returning immediately.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- testing
- Loại issue
- Lỗi
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100