Skip to content

Commit b4e17a3

Browse files
feat: Add Gecko driver options (appium#735)
1 parent 0a0cff2 commit b4e17a3

File tree

5 files changed

+180
-0
lines changed

5 files changed

+180
-0
lines changed
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+
ANDROID_STORAGE = 'androidStorage'
23+
24+
25+
class AndroidStorageOption(SupportsCapabilities):
26+
@property
27+
def android_storage(self) -> Optional[str]:
28+
"""
29+
The currently set storage type.
30+
"""
31+
return self.get_capability(ANDROID_STORAGE)
32+
33+
@android_storage.setter
34+
def android_storage(self, value: str) -> None:
35+
"""
36+
See https://firefox-source-docs.mozilla.org/testing/geckodriver
37+
/Flags.html#code-android-storage-var-android-storage-var-code
38+
"""
39+
self.set_capability(ANDROID_STORAGE, value)

appium/options/gecko/base.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,31 @@
1919

2020
from appium.options.common.automation_name_option import AUTOMATION_NAME
2121
from appium.options.common.base import AppiumOptions
22+
from appium.options.common.system_port_option import SystemPortOption
23+
24+
from .android_storage_option import AndroidStorageOption
25+
from .firefox_options_option import FirefoxOptionsOption
26+
from .marionette_port_option import MarionettePortOption
27+
from .verbosity_option import VerbosityOption
2228

2329

2430
class GeckoOptions(
2531
AppiumOptions,
32+
AndroidStorageOption,
33+
FirefoxOptionsOption,
34+
MarionettePortOption,
35+
SystemPortOption,
36+
VerbosityOption,
2637
):
38+
@SystemPortOption.system_port.setter # type: ignore
39+
def system_port(self, value: int) -> None:
40+
"""
41+
The number of the port for the driver to listen on. Must be unique
42+
for each session. If not provided then the driver will try to detect
43+
it automatically.
44+
"""
45+
SystemPortOption.system_port.fset(self, value) # type: ignore
46+
2747
@property
2848
def default_capabilities(self) -> Dict:
2949
return {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 Any, Dict, Optional
19+
20+
from appium.options.common.supports_capabilities import SupportsCapabilities
21+
22+
FIREFOX_OPTIONS = 'moz:firefoxOptions'
23+
24+
25+
class FirefoxOptionsOption(SupportsCapabilities):
26+
@property
27+
def firefox_options(self) -> Optional[Dict[str, Any]]:
28+
"""
29+
Firefox options mapping.
30+
"""
31+
return self.get_capability(FIREFOX_OPTIONS)
32+
33+
@firefox_options.setter
34+
def firefox_options(self, value: Dict[str, Any]) -> None:
35+
"""
36+
See https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions
37+
"""
38+
self.set_capability(FIREFOX_OPTIONS, value)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
MARIONETTE_PORT = 'marionettePort'
23+
24+
25+
class MarionettePortOption(SupportsCapabilities):
26+
@property
27+
def marionette_port(self) -> Optional[int]:
28+
"""
29+
The number of the port for the Marionette server to listen on.
30+
"""
31+
return self.get_capability(MARIONETTE_PORT)
32+
33+
@marionette_port.setter
34+
def marionette_port(self, value: int) -> None:
35+
"""
36+
Selects the port for Geckodriver’s connection to the Marionette
37+
remote protocol. The existing Firefox instance must have Marionette
38+
enabled. To enable the remote protocol in Firefox, you can pass the
39+
-marionette flag. Unless the marionette.port preference has been
40+
user-set, Marionette will listen on port 2828, which is the default
41+
value for this capability.
42+
"""
43+
self.set_capability(MARIONETTE_PORT, 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+
VERBOSITY = 'verbosity'
23+
24+
25+
class VerbosityOption(SupportsCapabilities):
26+
@property
27+
def verbosity(self) -> Optional[str]:
28+
"""
29+
The verbosity level of driver logging.
30+
"""
31+
return self.get_capability(VERBOSITY)
32+
33+
@verbosity.setter
34+
def verbosity(self, value: str) -> None:
35+
"""
36+
The verbosity level of driver logging.
37+
By default, minimum verbosity is applied.
38+
Either 'debug' or 'trace'.
39+
"""
40+
self.set_capability(VERBOSITY, value)

0 commit comments

Comments
 (0)