You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ActionChains(driver).send_keys('A string to type.').perform()
46
+
ActionChains(driver).send_keys('A string to type.').perform()
48
47
49
48
50
49
### Absolute AXPath
51
50
This is a huge performance improvement, although it requires cooperation from the scripter. Instead of using a partial XPath, use a simple absolute AXPath. This is based on the OS X accessibility structure, which you can view in Accessibility Inspector. The paths are "simple" because only a limited subset of XPath syntax is supported. Locating objects by XPath is highly optimized when using absolute AXPaths.
52
51
53
52
A simple absolute AXPath:
54
53
55
-
* is a string with valid XPath syntax
56
-
* uses OS X Accessibility constants, e.g. AXMenuItem or AXTitle
57
-
* can specify any accessible element on the screen, in any application or window, any time
58
-
* begins with /AXApplication, and contains at least one other node
59
-
* does not contain "//", or use a wildcard, or specify multiple paths using |
60
-
* uses predicates with a single integer for an index, or, one or more string comparisons using = and !=
61
-
* may use boolean operators "and" or "or" (mutually exclusive) in between multiple comparisons
62
-
* there must be a leading and trailing space, e.g. " and "
63
-
* does not use predicate strings containing braces [] or parens ()
64
-
* uses single quotes, not double quotes for attribute strings
65
-
* does not contain spaces, except within attribute string values (optional), and, surrounding boolean operators (required)
66
-
54
+
* is a string with valid XPath syntax
55
+
* uses OS X Accessibility constants, e.g. AXMenuItem or AXTitle
56
+
* can specify any accessible element on the screen, in any application or window, any time
57
+
* begins with /AXApplication, and contains at least one other node
58
+
* does not contain "//", or use a wildcard, or specify multiple paths using |
59
+
* uses predicates with a single integer for an index, or, one or more string comparisons using = and !=
60
+
* may use boolean operators "and" or "or" (mutually exclusive) in between multiple comparisons
61
+
* there must be a leading and trailing space, e.g. " and "
62
+
* does not use predicate strings containing braces [] or parens ()
63
+
* uses single quotes, not double quotes for attribute strings
64
+
* does not contain spaces, except within attribute string values (optional), and, surrounding boolean operators (required)
65
+
67
66
Notes:
68
67
69
-
* The node "/AXApplication" without a predicate denotes the frontmost application.
70
-
* Attribute values nil and '' (empty string) are defined to be equivalent.
71
-
* For example, if a menu item does not have a mark character (i.e. the value is nil) then @AXMenuItemMarkChar=='' is true.
72
-
* Index predicates are valid for nodes with the same AXRole. For example, AXGroup[0] refers to the first AXGroup, not simply the first child element.
68
+
* The node "/AXApplication" without a predicate denotes the frontmost application.
69
+
* Attribute values nil and '' (empty string) are defined to be equivalent.
70
+
* For example, if a menu item does not have a mark character (i.e. the value is nil) then @AXMenuItemMarkChar=='' is true.
71
+
* Index predicates are valid for nodes with the same AXRole. For example, AXGroup[0] refers to the first AXGroup, not simply the first child element.
(leading and trailing spaces required for the boolean operator)
108
-
109
-
"/AXApplication[@AXTitle="Calculator"]/AXWindow[0]/AXButton[@AXDescription='clear' and @AXEnabled='YES' or @AXDescription='clear all']"
110
-
(predicate uses multiple kinds of boolean operators; use one or more 'and', or, use one or more 'or', but not both)
108
+
"/AXApplication[@AXTitle="Calculator"]/AXWindow[0]/AXButton[@AXDescription='clear' and @AXEnabled='YES' or @AXDescription='clear all']"
109
+
(predicate uses multiple kinds of boolean operators; use one or more 'and', or, use one or more 'or', but not both)
111
110
112
111
113
112
### Implicit Timeouts
114
113
AppumForMac supports standard implicit timeouts when finding an element. Pass a milliseconds value as a desired capability. The default is 0.0 seconds, that is, there will be only one attempt.
115
114
116
-
For example, 'implicitTimeout':20000 will retry for 20 seconds before returning an error.
115
+
For example, 'implicitTimeout':20000 will retry for 20 seconds before returning an error.
117
116
118
117
### Loop Delay
119
118
During an implicit timeout to find an element, you can specify how long to wait between attempts. Pass a milliseconds value as a desired capability. The default is 1.0 seconds. The loop delay occurs _after_ each attempt, so if the element is found on the first attempt, there will be no delay. The total waiting time will not exceed implicitTimeout, regardless of the loopDelay value.
120
119
121
-
For example, 'loopDelay':1000 will wait 1 second between each attempt.
120
+
For example, 'loopDelay':1000 will wait 1 second between each attempt.
122
121
123
122
### Command Delay
124
123
This provides a simple way to slow down a script if needed, e.g. for debugging. It specifies an arbitrary delay _before_ each command. Pass a milliseconds value as a desired capability. The default is 0.0 seconds so your script runs at full speed!
125
124
126
-
For example, 'commandDelay':2500 will wait 2.5 seconds before executing each command.
125
+
For example, 'commandDelay':2500 will wait 2.5 seconds before executing each command.
127
126
128
127
### Mouse Move Speed
129
128
For native mouse events, this determines how fast the mouse moves across the screen, in pixels per second. Several examples are in /examples/calculator.py.
130
129
131
-
For example, 'mouseMoveSpeed':100 will move about 2x faster than 'mouseMoveSpeed':50.
132
-
133
-
Be careful setting mouse speed too high, or your application may not detect the mouse-over for some elements.
130
+
For example, 'mouseMoveSpeed':100 will move about 2x faster than 'mouseMoveSpeed':50.
131
+
132
+
Be careful setting mouse speed too high, or your application may not detect the mouse-over for some elements.
134
133
135
134
### Session Diagnostics Directories
136
135
AppiumForMac can create a directory for all diagnostics, named "AppiumDiagnostics". This will contain other items such as per-session diagnostic directories. The per-session directory stores items like screen shots. Pass a string file path in as a desiredCapability. If you do not pass any path, then there will be no diagnostic records, such as screen shots.
137
136
138
-
For example, "diagnosticsDirectoryLocation":"~/Documents/" will add a directory named AppiumDiagnostics to your Documents folder.
137
+
For example, "diagnosticsDirectoryLocation":"~/Documents/" will add a directory named AppiumDiagnostics to your Documents folder.
139
138
140
139
### Screen Shots
141
140
AppiumForMac can take a screen shot automatically whenever an element is not found before the implicit timeout. These can be used to analyze errors. The screen shots are stored in the per-session diagnostic directory. Pass in a non-zero number as a desiredCapability to enable the feature. If you pass in zero, or do not provide this desiredCapability, then there will be no screen shots.
142
141
143
-
For example, "screenShotOnError":1 will enable automatic screen shots when find element fails.
144
-
145
-
For example, "screenShotOnError":0 will disable screen shots.
142
+
For example, "screenShotOnError":1 will enable automatic screen shots when find element fails.
143
+
144
+
For example, "screenShotOnError":0 will disable screen shots.
146
145
147
146
148
147
@@ -170,19 +169,19 @@ There is no more need to update the giant httpResponseForMethod:URI: method. The
170
169
1. Your handler is automatically called whenever AppiumForMac receives its matching wire protocol request.
171
170
1. Your handler code block receives three arguments: session, commandParams, and status.
172
171
173
-
* session: The AfMSessionController instance created when your script created a new web driver. This provides access to the machine and other applications.
174
-
* commandParams: A dictionary containing http request parameters. It includes elements referenced from the URL path, and all POST json objects. The "elementObject" dictionary key retrieves a validated element.
175
-
* status: A pointer to an int to write back a status code to your caller. This is not a substitute for your handler return value.
176
-
172
+
* session: The AfMSessionController instance created when your script created a new web driver. This provides access to the machine and other applications.
173
+
* commandParams: A dictionary containing http request parameters. It includes elements referenced from the URL path, and all POST json objects. The "elementObject" dictionary key retrieves a validated element.
174
+
* status: A pointer to an int to write back a status code to your caller. This is not a substitute for your handler return value.
175
+
177
176
1. Your code block should return an object created with [AppiumMacHTTPJSONResponse responseWithJson:status:session:] or [AppiumMacHTTPJSONResponse responseWithJsonError:session:].
178
177
1. If your code block returns responseWithJsonError:kAfMStatusCodeNoSuchElement, then the block (not the entire handler method) will be automatically called again, within the constraints of implicitTimeout, and loopDelay.
179
178
1. However, if your block returns nil, then a kAfMStatusCodeNoSuchElement error is _immediately_ returned to the scripter, even if implicitTimeout has not yet been reached.
180
179
1. If you expect thrown exceptions, add them to your own code block. Execution exceptions which you do not catch are logged but not re-thrown.
181
180
1. AppiumForMac automatically returns common errors to the scripter so you don't need to worry about them:
182
181
183
-
* There is no session with the sessionId specified in the request path.
184
-
* The specified element is invalid.
185
-
* Your handler returned kAfMStatusCodeNoSuchElement, but the implicitTimeout period was exceeded.
186
-
* Your handler doesn't exist (or you named it incorrectly).
187
-
* Your handler returned a nil value.
182
+
* There is no session with the sessionId specified in the request path.
183
+
* The specified element is invalid.
184
+
* Your handler returned kAfMStatusCodeNoSuchElement, but the implicitTimeout period was exceeded.
185
+
* Your handler doesn't exist (or you named it incorrectly).
0 commit comments