เรียกใช้สคริปต์ Robo (iOS+)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เอกสารนี้อธิบายวิธีใช้สคริปต์ Robo ซึ่งเป็นการทดสอบที่ทำให้งาน QA ด้วยตนเองสำหรับแอปบนอุปกรณ์เคลื่อนที่เป็นแบบอัตโนมัติ และช่วยให้การรวมอย่างต่อเนื่อง (CI) และกลยุทธ์การทดสอบก่อนเปิดตัวเป็นไปได้ เช่น คุณสามารถใช้สคริปต์ Robo เพื่อทดสอบเส้นทางทั่วไปของผู้ใช้ หรือระบุอินพุตของอินเทอร์เฟซผู้ใช้ (UI) ที่เฉพาะเจาะจง เช่น ชื่อผู้ใช้และรหัสผ่าน สคริปต์ Robo เป็นฟีเจอร์ของ Robo
test
สคริปต์ Robo ใช้การทดสอบ Robo
เป็นเครื่องมือทดสอบ ในรูปแบบพื้นฐานที่สุด สคริปต์ Robo ประกอบด้วยลำดับการดำเนินการ UI เช่น ป้อนข้อความ "ชื่อผู้ใช้" แล้วแตะปุ่มตกลง สคริปต์ Robo ยังสามารถรวมการดำเนินการต่างๆ เช่น การรอ
ให้องค์ประกอบปรากฏ การแตะที่จุดใดจุดหนึ่งภายในองค์ประกอบ และ
การเรียกใช้คำสั่งเชลล์ของ Android Debug Bridge (adb
)
สคริปต์ Robo มีข้อดีกว่าเฟรมเวิร์กการทดสอบแบบเดิมดังนี้
ความสามารถ
|
คำอธิบาย
|
มีความทนทานสูง
|
สคริปต์ Robo สามารถรองรับความแตกต่างด้านโครงสร้างและลักษณะการทำงานที่สำคัญระหว่างเวอร์ชันของแอปและความไม่เสถียรของแอปได้
|
คำถามปลายเปิด
|
หลังจากสคริปต์ Robo เสร็จสมบูรณ์แล้ว การทดสอบ Robo พื้นฐานจะเข้ามาแทนที่และทดสอบแอปต่อไป แนวทางการทดสอบอย่างต่อเนื่องนี้ช่วยให้ใช้กรณีการใช้งานที่สำคัญหลายอย่างได้ ตัวอย่างเช่น คุณสามารถใช้สคริปต์ Robo เพื่อนำ
แอปไปสู่สถานะหนึ่งๆ ได้โดยการดำเนินการขั้นตอนการลงชื่อเข้าใช้ที่กำหนดเอง
|
บันทึกได้
|
คุณไม่จำเป็นต้องเขียนโค้ดสคริปต์ Robo ด้วยตนเอง คุณบันทึกสคริปต์ได้โดยใช้
เครื่องมือบันทึกสคริปต์ Robo ใน Android Studio โดยปกติแล้วการสร้างหรือแก้ไขสคริปต์ Robo
ไม่จำเป็นต้องมีความรู้ด้านการพัฒนาแอปบนอุปกรณ์เคลื่อนที่
|
ยืดหยุ่น
|
สคริปต์ Robo สามารถโต้ตอบกับองค์ประกอบ UI ที่ไม่ใช่เนทีฟซึ่งพบได้ทั่วไปใน
เกม
|
สคริปต์ Robo จะทริกเกอร์แบบมีเงื่อนไขระหว่างการทดสอบ Robo ซึ่งช่วยให้ผู้ใช้
เพิ่มลักษณะการทำงานของ Robo ได้ โดยปกติแล้วเพื่อเพิ่มความครอบคลุมหรือกำหนดเป้าหมาย
ฟังก์ชันการทำงานที่เฉพาะเจาะจง สคริปต์ Robo รองรับสิ่งต่อไปนี้ ซึ่งแตกต่างจากเฟรมเวิร์กการทดสอบแบบเดิม
- เงื่อนไขการทริกเกอร์ต่างๆ เช่น ชื่อแพ็กเกจแอปหนึ่งๆ
ที่ใช้งานอยู่ (หรือไม่) หรือองค์ประกอบหนึ่งๆ ที่แสดงบนหน้าจอ
(หรือไม่)
- การควบคุมการดำเนินการ เช่น จำนวนการดำเนินการสูงสุด ลำดับความสำคัญ
ขั้นตอนการ Crawl ที่เกี่ยวข้อง
- ประเภทการทำงานที่ไม่ธรรมดา (ตามเงื่อนไข ไม่สนใจองค์ประกอบ ปิดหน้าจอ)
เราขอแนะนำให้คุณใช้สคริปต์ Robo ทุกครั้งที่เป็นไปได้ เนื่องจากสคริปต์เหล่านี้ดูแลรักษาได้ง่าย
เช่น คุณสามารถใช้สคริปต์ Robo เพื่อทำสิ่งต่อไปนี้
- ไปยังขั้นตอนการทำงานที่สำคัญเพื่อดูแก่นของฟังก์ชันการทำงานของแอป
เช่น คุณสามารถลงชื่อเข้าใช้ ตั้งค่าสถานะของแอปหลังจาก
เปิดตัวครั้งแรก และลงทะเบียนผู้ใช้ใหม่
- มุ่งเน้น Robo ไปที่ส่วนใดส่วนหนึ่งของแอปเพื่อใช้เวลาในการทดสอบ Robo ให้เกิดประโยชน์สูงสุด
สคริปต์ Robo จะนำทางการทดสอบ Robo ให้ไปถึงส่วนที่เกี่ยวข้องของแอป
ซึ่งการทดสอบ Robo จะกลับมาทำการ Crawl โดยอัตโนมัติอย่างเต็มรูปแบบ
- นำแอปไปยังสถานะหรือหน้าจอที่เฉพาะเจาะจงเพื่อทำการวิเคราะห์ เช่น วิเคราะห์ข้อความในแอป นโยบายความเป็นส่วนตัว หรือระดับที่เฉพาะเจาะจงของเกม
- ทำการทดสอบการวัดผลแบบครบวงจรโดยมีหรือไม่มีการทดสอบ Robo
ดำเนินการ Crawl โดยอัตโนมัติอย่างเต็มรูปแบบต่อหลังจากสคริปต์ Robo เสร็จสมบูรณ์
ใช้ฟีเจอร์สคริปต์ Robo ขั้นสูงเพิ่มเติมเพื่อทำสิ่งต่อไปนี้
- ดำเนินการก่อนที่ Robo จะเริ่มทำการ Crawl แอปที่อยู่ระหว่างทดสอบหรือหลังจากที่ทำการ Crawl เสร็จแล้ว เช่น ล้างข้อมูลแอปที่อยู่ระหว่างทดสอบก่อนทำการ Crawl หรือเปลี่ยนการตั้งค่าอุปกรณ์
- เปลี่ยนลักษณะการทำงานของ Robo ระหว่างการ Crawl โดยเฉพาะอย่างยิ่ง
- ทำให้ Robo ละเว้นวิดเจ็ต UI หรือหน้าจอแอปบางรายการ
- ระบุการดำเนินการที่กำหนดเองเพื่อให้ Robo ดำเนินการเมื่อย้อนกลับจากหน้าจอหนึ่งๆ
- กำหนดให้ Robo ดำเนินการที่เฉพาะเจาะจงเมื่อใดก็ตามที่พบหน้าจอแอปหนึ่งๆ ในระหว่างการ Crawl
- ปรับแต่งวิธีที่ Robo ทำการ Crawl ได้อย่างเต็มที่ เช่น ใช้ชุดการดำเนินการแบบมีเงื่อนไขและไม่มีเงื่อนไขเพื่อรักษาสถานะของแอปที่อยู่ระหว่างทดสอบไว้ในเบื้องหลังตลอดการ Crawl ขณะที่ทำการจัดการอุปกรณ์และปิดกล่องโต้ตอบแบบป๊อปอัปที่ปรากฏขึ้นระหว่างทาง
โปรดทราบว่าสคริปต์ Robo ไม่ได้แทนที่การทดสอบทุกประเภท คุณยังคงต้องมีการทดสอบหน่วยเพื่อตรวจจับข้อบกพร่องของตรรกะระดับต่ำในแอป โดยปกติแล้วการทดสอบเหล่านี้ไม่จำเป็นต้องใช้สภาพแวดล้อม Android หรือ iOS เราขอแนะนำให้คุณ
เสริมการทดสอบสคริปต์ Robo ด้วยการทดสอบเครื่องมือที่กำหนดเป้าหมายซึ่งอาจมี
การยืนยันแบบละเอียดที่เฉพาะเจาะจงเกี่ยวกับตรรกะทางธุรกิจ ซึ่งแสดงได้ดีที่สุด
ในโค้ด
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-16 UTC
[null,null,["อัปเดตล่าสุด 2025-08-16 UTC"],[],[],null,["\u003cbr /\u003e\n\nThis document describes how to use *Robo scripts* , which are tests that automate\nmanual QA tasks for mobile apps, and enable continuous integration (CI) and\npre-launch testing strategies. For example, you can use Robo scripts to test a\ncommon user journey or provide specific user interface (UI) input, like a\nusername and password. Robo scripts are a feature of [Robo\ntest](/docs/test-lab/ios/robo-ux-test).\n\nRobo scripts use [Robo test](/docs/test-lab/android/robo-ux-test)\nas the test engine. In its most basic form, a Robo script consists of a\nsequence of UI actions like *enter text 'username'* and\nthen *tap the OK button* . Robo scripts can also include actions like waiting\nfor an element to appear, tapping at a specific point within an element, and\nexecuting Android Debug Bridge (`adb`) shell commands.\n\nRobo scripts have the following advantages over traditional testing frameworks:\n\n|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Capability** | **Description** |\n| Highly robust | Robo scripts can tolerate significant structural and behavioral differences between app versions and app flakiness. |\n| Open-ended | After a Robo script completes, the base Robo test can take over and continue testing the app. This continued testing approach enables several key use cases. For example, you can use a Robo script to bring an app into a particular state by performing a custom sign-in flow. |\n| Recordable | You don't need to code Robo scripts manually. They can be recorded using the Robo script recorder in Android Studio. Creating or modifying Robo scripts typically doesn't require any knowledge of mobile development. |\n| Flexible | Robo scripts can interact with non-native UI elements that are common in games. |\n\nRobo scripts are conditionally triggered during a Robo test, which lets users\naugment Robo's behavior - typically to achieve greater coverage or target\nspecific functionality. In contrast to traditional testing frameworks,\nRobo scripts support the following:\n\n- Various triggering conditions, for example, a particular app package name being active (or not) or a specific element being displayed on the screen (or not).\n- Execution controls, for example, a maximum number of executions, priority, relevant crawl stage.\n- Unconventional action types (conditional, element-ignoring, screen-closing).\n\nWe recommend that you use Robo scripts whenever possible because they can be\nmaintained effortlessly. For example, you can use a Robo script to do the\nfollowing:\n\n- Navigate significant workflows to get to the core of an app's functionality. For example, you can perform a sign-in, set up an app's state after the first launch, and register a new user.\n- Focus Robo on a particular part of an app to get the most out of Robo test time. Robo script guides Robo test to reach the relevant part of an app, where Robo test resumes a fully automated crawl.\n- Bring an app into a specific state or screen to perform an analysis, for example, to analyze an in-app message, privacy policy, or specific level of a game.\n- Perform an end-to-end instrumentation test, with or without Robo test resuming a fully automated crawl after the Robo script is complete.\n\nUse more advanced Robo script features to do the following:\n\n- Perform actions before Robo starts crawling the app-under-test or after a crawl is finished, for example, clean the app-under-test data before a crawl, or change device settings.\n- Change aspects of Robo behavior during a crawl, in particular:\n - Make Robo ignore some UI widgets or app screens.\n - Provide a custom action for Robo to perform when backtracking from a particular screen.\n - Make Robo perform specific actions whenever a particular app screen is encountered during a crawl.\n- Completely customize how Robo performs a crawl. For example, use a combination of conditional and non-conditional actions to keep the app-under-test in the background throughout the crawl, while performing device manipulations and dismissing any popup dialogs that appear along the way.\n\nKeep in mind that Robo scripts don't replace all kinds of tests. You still\nneed unit tests to catch low-level logic bugs in your app; these tests\ntypically don't require an Android or iOS environment. We recommend that you\nsupplement Robo script tests with targeted instrumentation tests that can have\nspecific, detailed assertions about business logic, which are best expressed\nin code.\n\nNext steps\n\n- To learn about Robo scripts structure, capabilities, usage, and actions, see\n the [Robo scripts reference guide](/docs/test-lab/android/robo-scripts-reference#ios-support-for-robo-scripts).\n\n- [Run a Robo test](/docs/test-lab/ios/robo-ux-test)."]]