{"record":{"id":"1490924d47a2862a","repo":"SeleniumHQ/selenium","slug":"orientation-value-must-be-one-of-self-orientation","errorCode":null,"errorMessage":"Orientation value must be one of {self.ORIENTATION_VALUES}","messagePattern":"Orientation value must be one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/print_page_options.py","lineNumber":117,"sourceCode":"        if value < 0.1 or value > 2:\n            raise ValueError(\"Value of scale should be between 0.1 and 2\")\n        obj._print_options[self.name] = value\n\n\nclass _PageOrientationDescriptor:\n    \"\"\"PageOrientation descriptor which validates orientation of page.\"\"\"\n\n    ORIENTATION_VALUES = [\"portrait\", \"landscape\"]\n\n    def __init__(self, name):\n        self.name = name\n\n    def __get__(self, obj, cls) -> Orientation | None:\n        return obj._print_options.get(self.name, None)\n\n    def __set__(self, obj, value) -> None:\n        if value not in self.ORIENTATION_VALUES:\n            raise ValueError(f\"Orientation value must be one of {self.ORIENTATION_VALUES}\")\n        obj._print_options[self.name] = value\n\n\nclass _ValidateTypeDescriptor:\n    \"\"\"Base Class Descriptor which validates type of any subclass attribute.\"\"\"\n\n    def __init__(self, name, expected_type: type):\n        self.name = name\n        self.expected_type = expected_type\n\n    def __get__(self, obj, cls):\n        return obj._print_options.get(self.name, None)\n\n    def __set__(self, obj, value) -> None:\n        if not isinstance(value, self.expected_type):\n            raise ValueError(f\"{self.name} should be of type {self.expected_type.__name__}\")\n        obj._print_options[self.name] = value\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/print_page_options.py#L99-L135","documentation":"The orientation property on PrintOptions only accepts 'portrait' or 'landscape' (lowercase). Any other value raises ValueError. The allowed values are stored in ORIENTATION_VALUES and interpolated into the message.","triggerScenarios":"Setting print_options.orientation = 'Portrait' (capitalized), 'horizontal', 'vertical', or '0'. The check is case-sensitive lowercase.","commonSituations":"Capitalizing the value. Using synonyms ('vertical'/'horizontal'). Pulling orientation from an enum or external source with different naming.","solutions":["Use exactly 'portrait' or 'landscape' (lowercase).","Lowercase external input before assigning: value.lower()."],"exampleFix":"# before\nprint_options.orientation = 'Portrait'  # raises ValueError\n\n# after\nprint_options.orientation = 'portrait'\n# or normalize\nprint_options.orientation = user_input.strip().lower() if user_input.strip().lower() in ('portrait','landscape') else 'portrait'","handlingStrategy":"validation","validationCode":"ALLOWED = {'portrait','landscape'}\nvalue = value.strip().lower()\nif value not in ALLOWED:\n    raise ValueError(f'orientation must be one of {sorted(ALLOWED)}')\nprint_options.orientation = value","typeGuard":"def is_valid_orientation(v: str) -> bool:\n    return isinstance(v, str) and v.strip().lower() in {'portrait','landscape'}","tryCatchPattern":"try:\n    print_options.orientation = value\nexcept ValueError:\n    print_options.orientation = 'portrait'","preventionTips":["Lowercase and strip external input before assigning.","Map synonyms ('vertical'->'portrait') in your config layer."],"tags":["print","orientation","validation"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}