SeleniumHQ/selenium · error · TypeError
service_args must be a sequence
Error message
service_args must be a sequence
What it means
Raised as TypeError by the InternetExplorerService.service_args setter when the value is a bare str or not a Sequence type. Identical to the Firefox service_args validation: a str is explicitly rejected (even though str is a Sequence) because it would be unpacked into individual characters. The value must be a list/tuple of string arguments.
Source
Thrown at py/selenium/webdriver/ie/service.py:95
executable_path=executable_path,
port=port,
log_output=log_output,
driver_path_env_key=driver_path_env_key,
**kwargs,
)
def command_line_args(self) -> list[str]:
return [f"--port={self.port}"] + self._service_args
@property
def service_args(self) -> Sequence[str]:
"""Returns the sequence of service arguments."""
return self._service_args
@service_args.setter
def service_args(self, value: Sequence[str]):
if isinstance(value, str) or not isinstance(value, Sequence):
raise TypeError("service_args must be a sequence")
self._service_args = list(value)
View on GitHub (pinned to aa36b38e69)
Solutions
- Wrap arguments in a list: service_args=['--verbose']
- Use shlex.split() to split a string into a proper argument list
- Pass a tuple of argument strings
Example fix
// before service = Service(service_args='--log-level=TRACE') // after service = Service(service_args=['--log-level=TRACE'])
Defensive patterns
Strategy: type-guard
Validate before calling
args = '--log-level=TRACE'
if isinstance(args, str):
args = [args]
service = Service(service_args=args) Type guard
from collections.abc import Sequence
def is_arg_sequence(v) -> bool:
return not isinstance(v, str) and isinstance(v, Sequence) Try / catch
try:
service.service_args = args
except TypeError:
service.service_args = [args] if isinstance(args, str) else list(args) Prevention
- Always pass service_args as a list of strings
- Never pass a bare string to service_args
- Use shlex.split() for space-separated argument strings
When it happens
Trigger: Passing service_args='--verbose' (single string) or service_args=123 (non-sequence) triggers the TypeError. Only list or tuple of strings is accepted.
Common situations: Developers passing a single CLI flag as a string. Passing a space-delimited string expecting automatic splitting.
Related errors
- service_args must be a sequence
- service_args must be a sequence
- {self.name} should be of type {self.expected_type.__name__}
- reuse must be a boolean
- service_args must be a sequence
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/34e7c444f0f13f17.
Report an issue: GitHub.