robotframework / robotframework/SeleniumLibrary

Discussion: Error messages

オープン
#1,933 コメント 3 件 リアクション 0 件 担当者 1 名 GitHub で見る

@emanlove がすでに取り組んでいます。

2025年8月7日 から。

enhancement help wanted pending priority: high
主要言語
Python
スター
1.5k
フォーク
787
PR マージ指標
30日以内にマージされた PR はありません

説明

I've been using SeleniumLibrary for a while now. It's been great. I have come across issues and headaches, but almost all of them are caused by Selenium itself :)

Context

We're using SeleniumLibrary within a significantly sized project with 10+ testers. Some of these testers are not well-versed in code or technical things. Because of this situation, I find myself wrapping most SeleniumLibrary keywords for two reasons: adding retrying behavior and enhancing the error messages. I want to focus on the second reason for this issue.

Our error messages

To me, the error messages are a form of documentation. Documentation that pops up the exact moment you need to know about something. Because of this idea, I write error messages like this:

Element is not visible | Page: 'https://example.com/page' | Element 'div.example.locator' not visible after 5 seconds | Screenshot: 0-FAIL-meaningful-name.png

This error message has the following parts:

  1. Element is not visible

    Short description without details. This is useful for quickly scanning multiple fails, especially in our pipeline test report. In the pipeline report, we only have the test name and the fail message. The short message allows you to decide if you want more details. If you do, you keep reading.

  2. Page: 'https://example.com/page'

    On what page did the error occur? This is useful for debugging and recognizing known issues. I think known issues should not exist, but reality teaches us that they happen. Being able to recognize them is never a bad thing.

  3. Element 'div.example.locator' not visible after 5 seconds

    The actual details of what went wrong. This part can consist of multiple parts, depending on the keyword. The idea is to give as many details as possible. These details are used to figure out what exactly happened. Other examples from our codebase include:

    Simple one:
    Could not scroll element 'div.example.locator' into view

    Multiple parts:
    Element 'div.example.locator' contains unexpected text after 5 seconds | 'Foo' (expected) in 'Who is this Foo fella?' (actual)

    Multiple parts with lots of details:
    Element 'div.example.locator img' attribute 'alt' does not contain 'foo' after 5 seconds | 'Amazing image alt tag contents' does not contain 'foo'

  4. Screenshot: 0-FAIL-meaningful-name.png

    The file name of the screenshot. This allows you to easily reference a screenshot if it was made. If no screenshot is made, this part will be Screenshot: [None].

Examples

Same example as above

Element is not visible | Page: 'https://example.com/page' | Element 'div.example.locator' not visible after 5 seconds | Screenshot: 0-FAIL-meaningful-name.png

Lots of details

Element attribute value does not contain expected value | Page: 'https://example.com/page' | Element 'div.example.locator' attribute 'class' does not contain 'foo' after 5 seconds | 'lorum ipsum' does not contain 'foo' | Screenshot: 0-FAIL-meaningful-name.png

Note that the 3rd part is the exact error from Wait until Location contains

Unexpected location | Page: 'https://example.com/page' | Location did not contain 'https://example.com/page' in 5 seconds. | Screenshot: 0-FAIL-meaningful-name.png

Note that the 3rd part is the exact error from Wait Until Element Is Enabled

Element is not enabled | Page: 'https://example.com/page' | Element 'div.example.locator' not enabled in 5 seconds | Screenshot: 0-FAIL-meaningful-name.png

Discussion topic

I'm a fan of solving something like this in a great way, only once, in the right place. I think the right place for these error messages is in SeleniumLibrary. I also think the existing error messages are pretty good but can be improved.

What do you think about adding (some of) these ideas to SeleniumLibrary?

Please note that I'm willing to help implement these changes.

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

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

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