> 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/autify-university/foundation/test-plans/url-replacements.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# URL置換

## URL置換とは？

企業サイトに変更を加える際、複数の環境を使い分けていませんか？ステージング環境、開発環境、本番環境などと呼ばれていますね。通常、環境ごとにURLは異なりますが、テストされるサイトは同じです。

Autifyの「URL置換」をご利用いただくと、新しいシナリオをレコーディングしなくても、シナリオに含まれる特定のURLを一括置換してテストを実行できます。

## URL置換の設定

テストプラン詳細画面を開き、「シナリオ内のURL置換」で、**追加** をクリックしましょう。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-60aa4c604ff9f9cff8e77b5e06cfe213e1eac546%2FURL_replacement_1.png?alt=media)

置換されるURL (置換前) とこのURLに置換 (置換後) をそれぞれ指定し、**作成** をクリックします。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-5ff6e08bc74447e73074d10d9a1df9ae157e00d5%2FURL_replacement_2\(2\).png?alt=media)

また、置換したいURLが複数ある場合もそれぞれ置換することが可能です。

![](https://50135409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fof7cb8AGXhWvWThq3R0w%2Fuploads%2Fgit-blob-eaef1ef9590779a2b4b1972f0104d0c5faa22f44%2FURL_replacement_3.png?alt=media)

「このURLに置換」に指定したURLは、「置換されるURL」と一致する、シナリオ内すべてのURLが置換対象となります。

## 置換対象のURL

テストプランを実行する際、下記置換対象のURLが「置換されるURL」から「このURLに置換」のURLに置換されてから実行されます。

* ステップ1の開始URL
* [ページ遷移ステップ](https://help.autify.com/nocode-web/autify-university/foundation/creating-a-scenario/go-to-url-button.md)のURL
* 入力ステップなどの入力値に含まれるURL
* 「URLが〇〇である/含むことを確認する」アサーションの期待値のURL
* [ページ内の要素に対するアサーション](https://help.autify.com/nocode-web/autify-university/advanced/assertions-1/assertion-elements-on-the-page.md)の期待値に含まれるURL
* [JSステップ](https://help.autify.com/nocode-web/autify-university/advanced/js-steps/javascript-steps.md)内のURL

  * URLがJSステップ内で動的に組み立てられる場合は対象外です。

  ```js
  // 置換対象
  return "https://autify.com"
  ```

  ```js
  // 置換対象外
  return "https://" + "autify.com"
  ```
* [ステップグループ](https://help.autify.com/nocode-web/autify-university/foundation/step-groups/step-groups-and-their-types.md)内のステップに含まれるURL
  * ステップグループの値を「置換されるURL」に上書きしている場合、「このURLに置換」に指定したURLに置換されます
* [JavaScriptスニペット内](https://help.autify.com/nocode-web/autify-university/advanced/js-steps/reusable-js-steps.md)のURL
* [データ](https://help.autify.com/nocode-web/autify-university/foundation/creating-a-scenario/creating-data.md)のURL

## 置換対象外のURL

以下のURLは置換対象外です。

* [変数](https://help.autify.com/nocode-web/autify-university/advanced/variables.md)に設定されたURL

## 利用例

具体的にシナリオ内のURLがどのように置換されるか3つのパターンを例に取り上げ解説します。 今回の例では、2つ「置換されるURL」があった場合を前提に、解説の便宜上それぞれ置換指定1と置換指定2とします。

パターン1について、シナリオ内のURLが「置換されるURL」と完全一致しているため、「このURLに置換」に指定したURLに置換されます。

また、置換を行う際に、「置換されるURL」の長さが長いものから順に適用されます。 そのため、パターン2については、置換指定1ではなく置換指定2が適用されます。

パターン3については、置換指定1が適用され、URLの前方が置換されます。

|       | 「置換されるURL」欄                         | 「このURLに置換」欄                           |
| ----- | ----------------------------------- | ------------------------------------- |
| 置換指定1 | https\://`dev`.example.com          | https\://`prd`.example.com            |
| 置換指定2 | https\://`dev`.example.com/project1 | https\://`prd`.example.com/project`A` |

|       | シナリオ内のURL                           | 置換後のURL                               | 使われた置換指定 |
| ----- | ----------------------------------- | ------------------------------------- | -------- |
| パターン1 | https\://`dev`.example.com          | https\://`prd`.example.com            | 置換指定1    |
| パターン2 | https\://`dev`.example.com/project1 | https\://`prd`.example.com/project`A` | 置換指定2    |
| パターン3 | https\://`dev`.example.com/home     | https\://`prd`.example.com/home       | 置換指定1    |

***

**※ご注意** 実行環境の異なるテストプランを作成するためにURL置換機能を使う場合、URL置換を考慮してシナリオ名を付けることをおすすめします。


---

# 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/autify-university/foundation/test-plans/url-replacements.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.
