3. Functions, Arguments & Python Modules

Reusable Helper Functions

def format_locator(selector_template: str, value: str) -> str:
    return selector_template.replace("{value}", value)

# Default arguments:
def wait_and_click(element, timeout: int = 10):
print(f"Waiting up to {timeout}s...")

Task

  • Implement format_user_xpath:
  • 1. Accept username string.
  • 2. Return f"//tr[contains(., '{username}')]//button".
💡Common doubts
Did you like the problem?
Lesson 3 of 16
Python
Loading code editor…
Next