MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / _convert_method_to_event_name

Method _convert_method_to_event_name

py/generate_bidi.py:626–636  ·  view source on GitHub ↗

Convert BiDi method suffix to friendly event name. Examples: "contextCreated" -> "context_created" "navigationStarted" -> "navigation_started" "userPromptOpened" -> "user_prompt_opened"

(method_suffix: str)

Source from the content-addressed store, hash-verified

624
625 @staticmethod
626 def _convert_method_to_event_name(method_suffix: str) -> str:
627 """Convert BiDi method suffix to friendly event name.
628
629 Examples:
630 "contextCreated" -> "context_created"
631 "navigationStarted" -> "navigation_started"
632 "userPromptOpened" -> "user_prompt_opened"
633 """
634 # Convert camelCase to snake_case
635 s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", method_suffix)
636 return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
637
638 def generate_code(self, enhancements: dict[str, Any] | None = None) -> str:
639 """Generate Python code for this module.

Callers 1

generate_codeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected