Sitelet https://github.com/appium/python-client/commit/312c229fa89b6387236553c6f036085a835d3ed8
Skip to content

Commit 312c229

Browse files
feat: Add Mac2Driver options (#730)
1 parent 0278ba8 commit 312c229

11 files changed

Lines changed: 429 additions & 0 deletions
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import List, Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
ARGUMENTS = 'arguments'
23+
24+
25+
class ArgumentsOption(SupportsCapabilities):
26+
@property
27+
def arguments(self) -> Optional[List[str]]:
28+
"""
29+
:Returns: Array of application command line arguments.
30+
"""
31+
return self.get_capability(ARGUMENTS)
32+
33+
@arguments.setter
34+
def arguments(self, value: List[str]) -> None:
35+
"""
36+
Set the array of application command line arguments. This capability is
37+
only going to be applied if the application is not running on session startup.
38+
"""
39+
self.set_capability(ARGUMENTS, value)

‎appium/options/mac/mac2/base.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,32 @@
2222
from appium.options.common.postrun_option import PostrunOption
2323
from appium.options.common.prerun_option import PrerunOption
2424

25+
from .arguments_option import ArgumentsOption
26+
from .bootstrap_root_option import BootstrapRootOption
27+
from .bundle_id_option import BundleIdOption
28+
from .environment_option import EnvironmentOption
29+
from .server_startup_timeout_option import ServerStartupTimeoutOption
30+
from .show_server_logs_option import ShowServerLogsOption
31+
from .skip_app_kill_option import SkipAppKillOption
32+
from .system_host_option import SystemHostOption
33+
from .system_port_option import SystemPortOption
34+
from .web_driver_agent_mac_url_option import WebDriverAgentMacUrlOption
35+
2536

2637
class Mac2Options(
2738
AppiumOptions,
2839
PrerunOption,
2940
PostrunOption,
41+
ArgumentsOption,
42+
BootstrapRootOption,
43+
BundleIdOption,
44+
EnvironmentOption,
45+
ServerStartupTimeoutOption,
46+
ShowServerLogsOption,
47+
SkipAppKillOption,
48+
SystemHostOption,
49+
SystemPortOption,
50+
WebDriverAgentMacUrlOption,
3051
):
3152
@property
3253
def default_capabilities(self) -> Dict:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
BOOTSTRAP_ROOT = 'bootstrapRoot'
23+
24+
25+
class BootstrapRootOption(SupportsCapabilities):
26+
@property
27+
def bootstrap_root(self) -> Optional[str]:
28+
"""
29+
:Returns: The full path to WebDriverAgentMac root folder where Xcode project
30+
of the server sources lives.
31+
"""
32+
return self.get_capability(BOOTSTRAP_ROOT)
33+
34+
@bootstrap_root.setter
35+
def bootstrap_root(self, value: str) -> None:
36+
"""
37+
Set the full path to WebDriverAgentMac root folder where Xcode project
38+
of the server sources lives. By default, this project is located in
39+
the same folder where the corresponding driver Node.js module lives.
40+
"""
41+
self.set_capability(BOOTSTRAP_ROOT, value)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
BUNDLE_ID = 'bundleId'
23+
24+
25+
class BundleIdOption(SupportsCapabilities):
26+
@property
27+
def bundle_id(self) -> Optional[str]:
28+
"""
29+
:Returns: The bundle identifier of the application to automate.
30+
"""
31+
return self.get_capability(BUNDLE_ID)
32+
33+
@bundle_id.setter
34+
def bundle_id(self, value: str) -> None:
35+
"""
36+
Set the bundle identifier of the application to automate, for example
37+
com.apple.TextEdit. This is an optional capability. If it is not provided
38+
then the session will be started without an application under test
39+
(actually, it will be Finder). If the application with the given
40+
identifier is not installed then an error will be thrown on session
41+
startup. If the application is already running then it will be moved to
42+
the foreground.
43+
"""
44+
self.set_capability(BUNDLE_ID, value)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Dict, Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
ENVIRONMENT = 'environment'
23+
24+
25+
class EnvironmentOption(SupportsCapabilities):
26+
@property
27+
def environment(self) -> Optional[Dict[str, str]]:
28+
"""
29+
:Returns: Application environment variables mapping.
30+
"""
31+
return self.get_capability(ENVIRONMENT)
32+
33+
@environment.setter
34+
def environment(self, value: Dict[str, str]) -> None:
35+
"""
36+
Set the dictionary of environment variables (name->value) that are going to be passed
37+
to the application under test on top of environment variables inherited from
38+
the parent process. This option is only going to be applied if the application
39+
is not running on session startup.
40+
"""
41+
self.set_capability(ENVIRONMENT, value)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from datetime import timedelta
19+
from typing import Optional, Union
20+
21+
from appium.options.common.supports_capabilities import SupportsCapabilities
22+
23+
SERVER_STARTUP_TIMEOUT = 'serverStartupTimeout'
24+
25+
26+
class ServerStartupTimeoutOption(SupportsCapabilities):
27+
@property
28+
def server_startup_timeout(self) -> Optional[timedelta]:
29+
"""
30+
:Returns: Get the timeout to wait util the WebDriverAgentMac
31+
project is built and started.
32+
"""
33+
value_ms = self.get_capability(SERVER_STARTUP_TIMEOUT)
34+
return None if value_ms is None else timedelta(milliseconds=value_ms)
35+
36+
@server_startup_timeout.setter
37+
def server_startup_timeout(self, value: Union[int, timedelta]) -> None:
38+
"""
39+
Set the timeout to wait util the WebDriverAgentMac
40+
project is built and started.
41+
"""
42+
self.set_capability(
43+
SERVER_STARTUP_TIMEOUT, value.microseconds // 1000 if isinstance(value, timedelta) else value
44+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
SHOW_SERVER_LOGS = 'showServerLogs'
23+
24+
25+
class ShowServerLogsOption(SupportsCapabilities):
26+
@property
27+
def show_server_logs(self) -> Optional[bool]:
28+
"""
29+
:Returns: Whether to show WDA server logs in the Appium log.
30+
"""
31+
return self.get_capability(SHOW_SERVER_LOGS)
32+
33+
@show_server_logs.setter
34+
def show_server_logs(self, value: bool) -> None:
35+
"""
36+
Set it to true in order to include xcodebuild output to the Appium
37+
server log. false by default.
38+
"""
39+
self.set_capability(SHOW_SERVER_LOGS, value)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
SKIP_APP_KILL = 'skipAppKill'
23+
24+
25+
class SkipAppKillOption(SupportsCapabilities):
26+
@property
27+
def skip_app_kill(self) -> Optional[bool]:
28+
"""
29+
:Returns: Whether to skip the termination of the application under test.
30+
"""
31+
return self.get_capability(SKIP_APP_KILL)
32+
33+
@skip_app_kill.setter
34+
def skip_app_kill(self, value: bool) -> None:
35+
"""
36+
Set whether to skip the termination of the application under test
37+
when the testing session quits. false by default. This capability
38+
is only going to be applied if bundleId is set.
39+
"""
40+
self.set_capability(SKIP_APP_KILL, value)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from typing import Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
SYSTEM_HOST = 'systemHost'
23+
24+
25+
class SystemHostOption(SupportsCapabilities):
26+
@property
27+
def system_host(self) -> Optional[str]:
28+
"""
29+
:Returns: The name of the host for the internal server to listen on.
30+
"""
31+
return self.get_capability(SYSTEM_HOST)
32+
33+
@system_host.setter
34+
def system_host(self, value: str) -> None:
35+
"""
36+
Set the name of the host for the internal server to listen on.
37+
If not provided then Mac2Driver will use the default host
38+
address 127.0.0.1. You could set it to 0.0.0.0 to make the
39+
server listening on all available network interfaces.
40+
It is also possible to set the particular interface name, for example en1.
41+
"""
42+
self.set_capability(SYSTEM_HOST, value)

0 commit comments

Comments
 (0)