> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/when-the-test-doesnt-work/test-issues/checkbox-assersion-troubleshooting.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# チェックボックスやラジオボタンのアサーションが失敗する

## チェックボックスやラジオボタンのアサーション

Autifyの[**チェックボックスのアサーション**](https://help.autify.com/nocode-web/autify-university/advanced/assertions-1/assertion-elements-on-the-page.md)では、チェックされていることやチェックされていないこと (以下、選択未選択) をアサーションすることが可能です。また、そのチェックボックスやラジオボタンが有効であることや無効であること (選択できる状態かできない状態か) もアサーション可能です。

一方で、対象webアプリケーションの実装内容によっては、意図しないテスト結果になることがあります。この記事では、チェックボックスに関連するトラブルシューティングを説明します。

### テスト実行で選択未選択のアサーションが失敗するケース

対象要素がinput要素ではない場合、チェックボックスの選択未選択の判断は、AutifyのML (Machine Learning) によって行われます。精度が足りなかった場合、要素の選択未選択状態を誤って判定し、以下のエラーが表示されます。

エラーメッセージ例

```
チェックボックスが未選択であるべきでしたが、選択されています。
チェックボックスが選択であるべきでしたが、選択されていません。
```

この場合は、以下のいずれかの機能で解決する場合があります。

* [クイック要素更新](https://help.autify.com/nocode-web/autify-university/foundation/test-results/quick-element-update.md)
* [ロケータ](https://help.autify.com/nocode-web/autify-university/advanced/locator-feature/add-a-locator.md)
* [要素に対するビジュアルリグレッションテスト](https://help.autify.com/nocode-web/autify-university/advanced/visual-testing/visual-regression-testing-for-elements.md)

クイック要素更新機能やロケータを使う場合、input要素を選択することがポイントです。これにより、input要素の選択状態 (checked属性) をAutifyが見れるようになり、正しく選択状態を判定できるようになる可能性があります。

input要素で実装をされていない場合 (divタグやspanタグなどにチェックボックス風のスタイルを当てて擬似的に作ったチェックボックスなど) は、JSステップを使ってスタイルを検証していただく必要があります。また、要素に対するビジュアルリグレッションテストを使うことで正しく判定できる可能性があります。

### レコーディング時に、チェックボックスの有効 / 無効のアサーションステップを追加できないケース

カスタムチェックボックスを実装している場合で、そのチェックボックスのinput要素を`display: none` などで非表示にしている場合、Autifyレコーダーが要素を検出できず、アサーションコマンドに「有効・無効のアサーション (対象が有効であることを確認する / 対象が無効であることを確認する) 」が表示されず、選択することができません。

レコーディング中にDevToolsを開き、input要素のスタイル `display: none` を一旦削除し、input要素を表示させることで対象が無効であること (もしくは有効であること) を確認するアサーションを追加することが可能です。ただし、テスト結果では、その要素は表示されないため、テスト結果のスクリーンショットでは対象とする要素にフォーカスがあたりません。

## それでも問題が解決しない場合...

いつでもカスタマーサポートチームにご連絡ください。問題を解決するお手伝いをいたします。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/when-the-test-doesnt-work/test-issues/checkbox-assersion-troubleshooting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
