MonkeyRunner
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מחלקת monkeyrunner שמכילה שיטות סטטיות של כלי עזר.
סיכום
שיטות |
void
|
alert
(string message,
string title,
string okTitle)
הפונקציה מציגה תיבת דו-שיח של התראה לתהליך שמריץ את התוכנית הנוכחית.
|
integer
|
choice
(string message,
iterable choices,
string title)
מוצגת תיבת דו-שיח עם רשימת אפשרויות לתהליך שבו פועלת התוכנית הנוכחית.
|
void
|
help
(פורמט מחרוזת)
הפלט יציג את הפניה ל-monkeyrunner API בסגנון דומה לזה של הכלי pydoc של Python, בפורמט שצוין.
|
string
|
input
(string message,
string initialValue,
string title,
string okTitle,
string cancelTitle)
הצגת תיבת דו-שיח לקבלת קלט.
|
void
|
sleep
(float seconds)
משהה את התוכנית הנוכחית למספר השניות שצוין.
|
MonkeyDevice
|
waitForConnection
(float timeout,
string deviceId)
מנסה ליצור חיבור בין הקצה העורפי monkeyrunner לבין המכשיר או האמולטור שצוינו.
|
שיטות ציבוריות
string
alert
(
string message,
string title,
string okTitle)
הפונקציה מציגה תיבת דו-שיח של התראה לתהליך שבו פועלת התוכנית הנוכחית. תיבת הדו-שיח היא מודלית, ולכן התוכנית מושהית עד שהמשתמש לוחץ על הלחצן בתיבת הדו-שיח.
ארגומנטים
הודעה |
ההודעה שתוצג בתיבת הדו-שיח.
|
title |
הכותרת של תיבת הדו-שיח. ערך ברירת המחדל הוא Alert.
|
okTitle |
הטקסט שמוצג בלחצן של תיבת הדו-שיח. ערך ברירת המחדל הוא OK.
|
integer
choice
(string message,
iterable choices,
string title)
מוצגת תיבת דו-שיח עם רשימת אפשרויות לתהליך שבו פועלת התוכנית הנוכחית. תיבת הדו-שיח היא מודלית, ולכן התוכנית מושהית עד שהמשתמש לוחץ על אחד מהלחצנים בתיבת הדו-שיח.
ארגומנטים
הודעה |
ההודעה שמוצגת בתיבת הדו-שיח.
|
אפשרויות |
אובייקט ניתן לחזרה (iterable) ב-Python שמכיל אובייקט אחד או יותר שמוצגים כמחרוזות. הפורמט המומלץ הוא מערך של מחרוזות.
|
title
|
הכותרת של תיבת הדו-שיח. ברירת המחדל היא 'קלט'.
|
החזרות
-
אם המשתמש בוחר אפשרות ולוחץ על הלחצן 'אישור', הפונקציה מחזירה את האינדקס מבוסס-האפס של הבחירה בתוך האובייקט שניתן לאיטרציה.
אם המשתמש לוחץ על הלחצן 'ביטול', השיטה מחזירה את הערך -1.
הפלט מציג את הפניה ל-monkeyrunner API בסגנון דומה לזה של הכלי pydoc
של Python, בפורמט שצוין.
ארגומנטים
פורמט |
פורמט התיוג שבו רוצים להשתמש בפלט. הערכים האפשריים הם 'text' לטקסט רגיל או 'html' ל-HTML.
|
הצגת תיבת דו-שיח שמקבלת קלט ומחזירה אותו לתוכנית. תיבת הדו-שיח היא מודלית, ולכן התוכנית מושהית עד שהמשתמש לוחץ על אחד מהלחצנים בתיבת הדו-שיח.
תיבת הדו-שיח מכילה שני לחצנים, שאחד מהם מציג את הערך okTitle
והשני את הערך cancelTitle. אם המשתמש לוחץ על הלחצן okTitle,
הערך הנוכחי של תיבת הקלט מוחזר. אם המשתמש לוחץ על הלחצן cancelTitle, מוחזרת מחרוזת ריקה.
ארגומנטים
הודעה |
ההודעה שמוצגת בתיבת הדו-שיח.
|
initialValue |
הערך הראשוני שיוצג בתיבת הדו-שיח. ברירת המחדל היא מחרוזת ריקה.
|
title |
הכותרת של תיבת הדו-שיח. ברירת המחדל היא 'קלט'.
|
okTitle |
הטקסט שמוצג בכפתור okTitle. ברירת המחדל היא "OK".
|
cancelTitle |
הטקסט שמוצג בלחצן cancelTitle. ברירת המחדל היא 'ביטול'.
|
החזרות
-
אם המשתמש לוחץ על הלחצן okTitle, השיטה מחזירה את הערך הנוכחי של תיבת הקלט של תיבת הדו-שיח. אם המשתמש לוחץ על הלחצן cancelTitle, השיטה מחזירה מחרוזת ריקה.
void
sleep
(
float seconds
)
משהה את התוכנית הנוכחית למספר השניות שצוין.
ארגומנטים
שניות |
מספר השניות להשהיה.
|
MonkeyDevice
waitForConnection
(float timeout,
string deviceId)
מנסה ליצור חיבור בין הקצה העורפי monkeyrunner
לבין המכשיר או האמולטור שצוינו.
ארגומנטים
פסק זמן |
מספר השניות להמתנה לחיבור. ברירת המחדל היא להמתין ללא הגבלת זמן.
|
deviceId
|
ביטוי רגולרי שמציין את המספר הסידורי של המכשיר או האמולטור. בנושא Android Debug Bridge מוסבר על המספרים הסידוריים של המכשירים והאמולטורים.
|
החזרות
-
מופע אחד (
MonkeyDevice
) של המכשיר או האמולטור. אפשר להשתמש באובייקט הזה כדי לשלוט במכשיר או באמולטור ולתקשר איתם.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# MonkeyRunner\n\nA monkeyrunner class that contains static utility methods.\n\nSummary\n-------\n\n| Methods ||||||||||||\n|------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|---|---|---|---|---|---|---|---|---|\n| void | [alert](#alert) (*string* message, *string* title, *string* okTitle) Displays an alert dialog to the process running the current program. |\n| *integer* | [choice](#choice) (*string* message, *iterable* choices, *string* title) Displays a dialog with a list of choices to the process running the current program. |\n| void | [help](#help) (*string* format) Displays the monkeyrunner API reference in a style similar to that of Python's `pydoc` tool, using the specified format. |\n| *string* | [input](#input) (*string* message, *string* initialValue, *string* title, *string* okTitle, *string* cancelTitle) Displays a dialog that accepts input. |\n| void | [sleep](#sleep) (*float* seconds) Pauses the current program for the specified number of seconds. |\n| ` `[MonkeyDevice](/tools/help/MonkeyDevice)` ` | [waitForConnection](#waitForConnection) (*float* timeout, *string* deviceId) Tries to make a connection between the `monkeyrunner` backend and the specified device or emulator. |\n\nPublic methods\n--------------\n\n#### *string*\nalert\n( *string* message, *string* title, *string* okTitle)\n\n\nDisplays an alert dialog to the process running the current\nprogram. The dialog is modal, so the program pauses until the user clicks the dialog's\nbutton. \n\n##### Arguments\n\n| message | The message to display in the dialog. |\n| title | The dialog's title. The default value is \"Alert\". |\n| okTitle | The text displayed in the dialog button. The default value is \"OK\". |\n|---------|---------------------------------------------------------------------|\n\n#### *integer*\nchoice\n(*string* message, *iterable* choices, *string* title)\n\n\nDisplays a dialog with a list of choices to the process running the current program. The\ndialog is modal, so the program pauses until the user clicks one of the dialog's\nbuttons. \n\n##### Arguments\n\n| message | The prompt message displayed in the dialog. |\n| choices | A Python iterable containing one or more objects that are displayed as strings. The recommended form is an array of strings. |\n| title | The dialog's title. The default is \"Input\". |\n|---------|------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- If the user makes a selection and clicks the \"OK\" button, the method returns the 0-based index of the selection within the iterable. If the user clicks the \"Cancel\" button, the method returns -1. \n\n#### void\nhelp\n(*string* format)\n\n\nDisplays the monkeyrunner API reference in a style similar to that of Python's\n`pydoc` tool, using the specified format. \n\n##### Arguments\n\n| format | The markup format to use in the output. The possible values are \"text\" for plain text or \"html\" for HTML. |\n|--------|-----------------------------------------------------------------------------------------------------------|\n\n#### *string*\ninput\n(*string* message *string* initialValue, *string* title, *string* okTitle, *string* cancelTitle)\n\n\nDisplays a dialog that accepts input and returns it to the program. The dialog is\nmodal, so the program pauses until the user clicks one of the dialog's buttons.\n\n\nThe dialog contains two buttons, one of which displays the okTitle value\nand the other the cancelTitle value. If the user clicks the okTitle button,\nthe current value of the input box is returned. If the user clicks the cancelTitle\nbutton, an empty string is returned. \n\n##### Arguments\n\n| message | The prompt message displayed in the dialog. |\n| initialValue | The initial value to display in the dialog. The default is an empty string. |\n| title | The dialog's title. The default is \"Input\". |\n| okTitle | The text displayed in the okTitle button. The default is \"OK\". |\n| cancelTitle | The text displayed in the cancelTitle button. The default is \"Cancel\". |\n|--------------|-----------------------------------------------------------------------------|\n\n##### Returns\n\n- If the user clicks the okTitle button, then the method returns the current value of the dialog's input box. If the user clicks the cancelTitle button, the method returns an empty string. \n\n#### void\nsleep\n( *float* seconds )\n\n\nPauses the current program for the specified number of seconds. \n\n##### Arguments\n\n| seconds | The number of seconds to pause. |\n|---------|---------------------------------|\n\n#### `\n`[MonkeyDevice](/tools/help/MonkeyDevice)`\n`\nwaitForConnection\n(*float* timeout, *string* deviceId)\n\n\nTries to make a connection between the `monkeyrunner` backend and the\nspecified device or emulator. \n\n##### Arguments\n\n| timeout | The number of seconds to wait for a connection. The default is to wait forever. |\n| deviceId | A regular expression that specifies the serial number of the device or emulator. See the topic [Android Debug Bridge](/tools/help/adb) for a description of device and emulator serial numbers. |\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- A [MonkeyDevice](/tools/help/MonkeyDevice) instance for the device or emulator. Use this object to control and communicate with the device or emulator."]]