{"record":{"id":"2b4ed650232b345a","repo":"SeleniumHQ/selenium","slug":"tag-name-can-not-be-null","errorCode":null,"errorMessage":"tag_name can not be null","messagePattern":"tag_name can not be null","errorType":"exception","errorClass":"WebDriverException","httpStatus":null,"severity":"warning","filePath":"py/selenium/webdriver/support/relative_locator.py","lineNumber":43,"sourceCode":"def with_tag_name(tag_name: str) -> \"RelativeBy\":\n    \"\"\"Start searching for relative objects using a tag name.\n\n    Args:\n        tag_name: The DOM tag of element to start searching.\n\n    Returns:\n        RelativeBy: Use this object to create filters within a `find_elements` call.\n\n    Raises:\n        WebDriverException: If `tag_name` is None.\n\n    Note:\n        This method is deprecated and may be removed in future versions.\n        Please use `locate_with` instead.\n    \"\"\"\n    warnings.warn(\"This method is deprecated and may be removed in future versions. Please use `locate_with` instead.\")\n    if not tag_name:\n        raise WebDriverException(\"tag_name can not be null\")\n    return RelativeBy({By.CSS_SELECTOR: tag_name})\n\n\ndef locate_with(by: ByType, using: str) -> \"RelativeBy\":\n    \"\"\"Start searching for relative objects your search criteria with By.\n\n    Args:\n        by: The method to find the element.\n        using: The value from `By` passed in.\n\n    Returns:\n        RelativeBy: Use this object to create filters within a `find_elements` call.\n\n    Example:\n        >>> lowest = driver.find_element(By.ID, \"below\")\n        >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, \"p\").above(lowest))\n    \"\"\"\n    assert by is not None, \"Please pass in a by argument\"","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/support/relative_locator.py#L25-L61","documentation":"The deprecated `locate` factory builds a RelativeBy and requires a non-empty tag_name; passing None or an empty value raises WebDriverException. It is deprecated in favor of locate_with and emits a DeprecationWarning.","triggerScenarios":"Calling locate(tag_name=None) or locate(''), typically carried over from old tutorials/code.","commonSituations":"Legacy code or copied examples still using locate() instead of locate_with().","solutions":["Migrate to locate_with(By, using) which is the supported, non-deprecated API.","If you must use locate(), provide a non-empty tag_name.","Address the DeprecationWarning rather than silencing it."],"exampleFix":"# before\nfrom selenium.webdriver.support.relative_locator import locate\nelements = driver.find_elements(locate(tag_name=\"p\"))\n\n# after\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.relative_locator import locate_with\nelements = driver.find_elements(locate_with(By.CSS_SELECTOR, \"p\"))","handlingStrategy":"validation","validationCode":"if not tag_name:\n    raise WebDriverException(\"tag_name can not be null\")\n# better: switch to locate_with(By, using)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer locate_with over the deprecated locate factory.","Eliminate locate() calls when upgrading selenium versions."],"tags":["relative-locator","deprecated","validation"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}