hjwp / hjwp/Book-TDD-Web-Dev-Python

ch11l032 - Typo in the test / issue with wait_for + truthiness

オープン
#116 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
514
フォーク
175
PR マージ指標
30日以内にマージされた PR はありません

説明

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 🙂

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
testing
issue の種類
バグ
難易度
1/5
見積もり時間
1時間未満
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。