Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] Feature 12760 for python service properties #14263

Open
wants to merge 13 commits into
base: trunk
Choose a base branch
from
1 change: 0 additions & 1 deletion py/selenium/webdriver/chrome/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.


from typing import List
from typing import Mapping
from typing import Optional
Expand Down
15 changes: 13 additions & 2 deletions py/selenium/webdriver/chromium/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from io import IOBase
from typing import List
from typing import Mapping
Expand Down Expand Up @@ -44,7 +45,7 @@ def __init__(
driver_path_env_key: str = None,
**kwargs,
) -> None:
self.service_args = service_args or []
self._service_args = service_args or []
driver_path_env_key = driver_path_env_key or "SE_CHROMEDRIVER"

if isinstance(log_output, str):
Expand All @@ -64,5 +65,15 @@ def __init__(
**kwargs,
)

@property
def service_args(self) -> List[str]:
return self._service_args

@service_args.setter
def service_args(self, value: List[str]):
if not isinstance(value, List):
raise TypeError("service args must be a List of strings")
self._service_args = value

def command_line_args(self) -> List[str]:
return [f"--port={self.port}"] + self.service_args
return [f"--port={self.port}"] + self._service_args
14 changes: 12 additions & 2 deletions py/selenium/webdriver/edge/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,25 @@ def __init__(
driver_path_env_key: str = None,
**kwargs,
) -> None:
self.service_args = service_args or []
self._service_args = service_args or []
driver_path_env_key = driver_path_env_key or "SE_EDGEDRIVER"

super().__init__(
executable_path=executable_path,
port=port,
service_args=service_args,
service_args=self.service_args,
log_output=log_output,
env=env,
driver_path_env_key=driver_path_env_key,
**kwargs,
)

@property
def service_args(self) -> List[str]:
return self._service_args

@service_args.setter
def service_args(self, value: List[str]):
if not isinstance(value, List):
raise TypeError("service args must be a List of strings")
self._service_args = value
20 changes: 15 additions & 5 deletions py/selenium/webdriver/firefox/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
driver_path_env_key: str = None,
**kwargs,
) -> None:
self.service_args = service_args or []
self._service_args = service_args or []
driver_path_env_key = driver_path_env_key or "SE_GECKODRIVER"

super().__init__(
Expand All @@ -57,9 +57,19 @@ def __init__(
)

# Set a port for CDP
if "--connect-existing" not in self.service_args:
self.service_args.append("--websocket-port")
self.service_args.append(f"{utils.free_port()}")
if "--connect-existing" not in self._service_args:
self._service_args.append("--websocket-port")
self._service_args.append(f"{utils.free_port()}")

def command_line_args(self) -> List[str]:
return ["--port", f"{self.port}"] + self.service_args
return ["--port", f"{self.port}"] + self._service_args

@property
def service_args(self) -> List[str]:
return self._service_args

@service_args.setter
def service_args(self, value: List[str]):
if not isinstance(value, List):
raise TypeError("service args must be a List of strings")
self._service_args = value
19 changes: 15 additions & 4 deletions py/selenium/webdriver/ie/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def __init__(
- log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
Default is "stdout".
"""
self.service_args = service_args or []

self._service_args = service_args or []
driver_path_env_key = driver_path_env_key or "SE_IEDRIVER"

if host:
self.service_args.append(f"--host={host}")
self._service_args.append(f"--host={host}")
if log_level:
self.service_args.append(f"--log-level={log_level}")
self._service_args.append(f"--log-level={log_level}")

super().__init__(
executable_path=executable_path,
Expand All @@ -63,4 +64,14 @@ def __init__(
)

def command_line_args(self) -> List[str]:
return [f"--port={self.port}"] + self.service_args
return [f"--port={self.port}"] + self._service_args

@property
def service_args(self) -> List[str]:
return self._service_args

@service_args.setter
def service_args(self, value: List[str]):
if not isinstance(value, List):
raise TypeError("service args must be a List of strings")
self._service_args = value
17 changes: 13 additions & 4 deletions py/selenium/webdriver/safari/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.


from typing import List
from typing import Mapping
from typing import Optional
Expand Down Expand Up @@ -45,11 +44,11 @@ def __init__(
driver_path_env_key: str = None,
**kwargs,
) -> None:
self.service_args = service_args or []
self._service_args = service_args or []
driver_path_env_key = driver_path_env_key or "SE_SAFARIDRIVER"

if enable_logging:
self.service_args.append("--diagnose")
self._service_args.append("--diagnose")

self.reuse_service = reuse_service
super().__init__(
Expand All @@ -61,7 +60,7 @@ def __init__(
)

def command_line_args(self) -> List[str]:
return ["-p", f"{self.port}"] + self.service_args
return ["-p", f"{self.port}"] + self._service_args

@property
def service_url(self) -> str:
Expand All @@ -77,3 +76,13 @@ def reuse_service(self, reuse: bool) -> None:
if not isinstance(reuse, bool):
raise TypeError("reuse must be a boolean")
self._reuse_service = reuse

@property
def service_args(self) -> List[str]:
return self._service_args

@service_args.setter
def service_args(self, value: List[str]):
if not isinstance(value, List):
raise TypeError("service args must be a List of strings")
self._service_args = value
13 changes: 12 additions & 1 deletion py/selenium/webdriver/webkitgtk/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import warnings
from typing import List
from typing import Mapping
Expand Down Expand Up @@ -59,4 +60,14 @@ def __init__(
)

def command_line_args(self) -> List[str]:
return ["-p", f"{self.port}"] + self.service_args
return ["-p", f"{self.port}"] + self._service_args

@property
def service_args(self) -> List[str]:
return self._service_args

@service_args.setter
def service_args(self, value: List[str]):
if not isinstance(value, List):
raise TypeError("service args must be a List of strings")
self._service_args = value
17 changes: 14 additions & 3 deletions py/selenium/webdriver/wpewebkit/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import List
from typing import Mapping
from typing import Optional
from typing import Sequence

from selenium.webdriver.common import service

Expand All @@ -40,11 +41,11 @@ def __init__(
executable_path: str = DEFAULT_EXECUTABLE_PATH,
port: int = 0,
log_output: Optional[str] = None,
service_args: Optional[List[str]] = None,
service_args: Optional[Sequence[str]] = None,
env: Optional[Mapping[str, str]] = None,
**kwargs,
):
self.service_args = service_args or []
self._service_args = service_args or []
super().__init__(
executable_path=executable_path,
port=port,
Expand All @@ -54,4 +55,14 @@ def __init__(
)

def command_line_args(self) -> List[str]:
return ["-p", f"{self.port}"] + self.service_args
return ["-p", f"{self.port}"] + self._service_args

@property
def service_args(self):
return self._service_args

@service_args.setter
def service_args(self, value):
if not isinstance(value, Sequence):
raise TypeError("service args must be a sequence")
self._service_args = value