> 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-mobile/using-autify-nocode-mobile/scenario-creation-and-maintenance/javascript-step.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# JavaScript ステップ

## JavaScriptステップとは？

JavaScriptステップとは、Autifyの「シナリオ」内でお客様ご自身で任意のJavaScriptを記述する機能です。 この機能を使うことで、Autifyの標準機能でサポートしていない操作やアサーションも実行できるようになります。 例えば、以下のようなユースケースでご利用可能です。

* メール内のワンタイムパスコードを取得し、後続ステップで入力
* 動的な日付やユーザー名を生成し、後続ステップで入力
* 要素の属性値を検証 また、`autify.mobile.getDriver`のメソッドを利用することで、Appiumのライブラリを参照し利用することも可能です。ぜひご利用ください。

{% hint style="info" %}
JavaScriptステップはバブリックベータ機能としての提供となります。 パブリックベータ機能について詳しく知りたい方は、[こちら](https://help.autify.com/nocode-mobile/faq/other-faq/what-is-public-beta.md)をご参照ください。
{% endhint %}

## JavaScriptステップをシナリオに追加する方法

1. JavaScriptステップを追加したいシナリオ詳細画面を開きます。
2. JavaScriptステップを追加したいステップの間にカーソルを移動させます。
3. **＋** をクリック、表示されるメニューから「JavaScriptステップを挿入」を選んでください。

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-8791f30a26b37c32d690855adb4fa14d562c1f66%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202025-09-01%2022.34.16.png?alt=media)
4. テキストエディタにJavaScriptのコードを入力します。コードは関数で囲ってありますから、シンタックスを入れる必要はありません。

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-a66a4e68685ebd963900f886af9c9e9cb4cadaf6%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202025-09-02%2022.42.43.png?alt=media)
5. 任意でステップに名前を付けたり、メモを記入したりできます。ステップの説明などにお役立てください。

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-71fb64892cd59a9817fb85ca97f8d38101593ed7%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202025-09-01%2022.38.08.png?alt=media)
6. **保存** をクリックし、シナリオを保存します。

## 「JavaScriptステップ」で取得・生成した値を入力ステップで使う

「JavaScriptステップ」で取得・生成した値は、`return`をすることで後続の入力ステップで使用することができます。

1. シナリオ詳細画面で`return`された値を使用するステップをクリックします。
2. 入力値のドロップダウンから、「他のステップから取得」を選び、どのJavaScriptステップがreturnした値を使用するか選びます。

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-a34fd8902e6ac504a48607c81e4339085c69d10a%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202025-09-02%207.27.48.png?alt=media)
3. シナリオを実行すると、テスト結果上で、実際に`return`した値を確認できます。

   ![](https://1076629499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fngfbmyfc37v4emfzEMM7%2Fuploads%2Fgit-blob-aaaa934fc20a69a7cbd5f6faf285d1dbc23079a0%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202025-09-02%207.34.32.png?alt=media)

{% hint style="warning" %}

* Javascriptステップ作成後、1度「保存」をすることで、後続ステップでJavascriptステップの値を利用できるようになります。
* Javascriptステップ内で`return`していない場合は、この値は`null`になります。
  {% endhint %}

## JavaScriptステップで利用可能な関数

NoCode Mobileでは、現状、サポートされている関数が限定されております。 サポートされている関数については、以下をご確認ください。

<table data-search="false"><thead><tr><th>タイトル</th><th>プラットフォーム</th><th>参照</th><th>備考</th></tr></thead><tbody><tr><td>autify.mobile.getDriver</td><td>Android, iOS</td><td>Non standard API</td><td>Appiumドライバーインスタンスを取得</td></tr><tr><td>driver.executeScript</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/webdriver/#executescript">https://webdriver.io/docs/api/webdriver/#executescript</a></td><td></td></tr><tr><td>driver.findElement</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/webdriver/#findelement">https://webdriver.io/docs/api/webdriver/#findelement</a></td><td></td></tr><tr><td>driver.findElements</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/webdriver/#findelements">https://webdriver.io/docs/api/webdriver/#findelements</a></td><td></td></tr><tr><td>element.click</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/click">https://webdriver.io/docs/api/element/click</a></td><td></td></tr><tr><td>element.getAttribute</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/getAttribute">https://webdriver.io/docs/api/element/getAttribute</a></td><td></td></tr><tr><td>element.getLocation</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/getLocation">https://webdriver.io/docs/api/element/getLocation</a></td><td></td></tr><tr><td>element.getTagName</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/getTagName">https://webdriver.io/docs/api/element/getTagName</a></td><td></td></tr><tr><td>element.getText</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/getText">https://webdriver.io/docs/api/element/getText</a></td><td></td></tr><tr><td>element.getValue</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/getValue">https://webdriver.io/docs/api/element/getValue</a></td><td></td></tr><tr><td>element.isDisplayed</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/isDisplayed">https://webdriver.io/docs/api/element/isDisplayed</a></td><td></td></tr><tr><td>element.setValue</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/element/setValue">https://webdriver.io/docs/api/element/setValue</a></td><td></td></tr><tr><td>element.longPress</td><td>Android, iOS</td><td><a href="https://webdriver.io/docs/api/mobile/longPress">https://webdriver.io/docs/api/mobile/longPress</a></td><td></td></tr><tr><td>fetch</td><td>Android, iOS</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API</a></td><td>標準のfetchとは完全な互換性はありません。</td></tr><tr><td>sleep</td><td>Android, iOS</td><td>Non standard API</td><td></td></tr></tbody></table>

## 留意点

Javascriptステップの検証や実装にあたっては、実際のアプリケーションのコードを確認しながら進める必要がある場合がございます。開発環境を構築いただく、もしくは、開発者の方のご協力の元、ご実装ください。 なお、本機能は、お客様ご自身による開発を前提とした機能となりますため、カスタマーサポートにて、お客様に代わってコードを作成することはできかねますので、あらかじめご了承ください。

## FAQ

* アサーションステップでの利用はできますか？
  * 現状、アサーションステップでJavascriptステップで取得した値を期待値として利用することはできません。
* 引数を使うことはできますか？
  * 現状、Javascriptステップで引数を使うことはできません。
* よく使う操作をスニペットとして登録できますか？
  * 現状、スニペットの登録はできません。
* NoCode WebのようなJavascriptスニペットの提供はありますか？
  * NoCode Mobileのみに向けたスニペットの提供はございませんが、NoCode Web向けのスニペットの一部は共通でご利用いただけます。ぜひご利用ください。
  * [Autify JavaScript Snippets](https://javascript-snippets.autify.com/ja/)


---

# 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-mobile/using-autify-nocode-mobile/scenario-creation-and-maintenance/javascript-step.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.
