{"record":{"id":"61cb244583a4bd3b","repo":"SeleniumHQ/selenium","slug":"value-of-scale-should-be-between-0-1-and-2","errorCode":null,"errorMessage":"Value of scale should be between 0.1 and 2","messagePattern":"Value of scale should be between 0\\.1 and 2","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/print_page_options.py","lineNumber":100,"sourceCode":"    def __set__(self, obj, value) -> None:\n        getattr(obj, \"_validate_num_property\")(f\"Margin {self.name}\", value)\n        obj._margin[self.name] = value\n        obj._print_options[\"margin\"] = obj._margin\n\n\nclass _ScaleDescriptor:\n    \"\"\"Scale descriptor which validates scale.\"\"\"\n\n    def __init__(self, name):\n        self.name = name\n\n    def __get__(self, obj, cls) -> float | None:\n        return obj._print_options.get(self.name)\n\n    def __set__(self, obj, value) -> None:\n        getattr(obj, \"_validate_num_property\")(self.name, value)\n        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","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/print_page_options.py#L82-L118","documentation":"The scale property on PrintOptions must be a number between 0.1 and 2.0 inclusive. It first validates the value is numeric (via _validate_num_property) and then checks the 0.1–2.0 range, raising ValueError if outside. This maps to the W3C print scale parameter controlling rendering zoom.","triggerScenarios":"Setting print_options.scale = 3, print_options.scale = 0, or print_options.scale = 0.05. A non-numeric value raises the earlier 'should be an integer or a float' error first.","commonSituations":"Assuming scale is a percentage (passing 100 instead of 1.0). Passing 0 to 'disable' scaling. Misreading the spec bounds.","solutions":["Set scale to a float in [0.1, 2.0], e.g. 1.0 for default, 2.0 for double size.","If you intended a percentage, divide by 100 (clamped to the range)."],"exampleFix":"# before\nprint_options.scale = 150  # out of range -> ValueError\n\n# after\nprint_options.scale = 1.5","handlingStrategy":"validation","validationCode":"if not isinstance(scale, (int, float)) or scale < 0.1 or scale > 2:\n    raise ValueError('scale must be a number in [0.1, 2.0]')\nprint_options.scale = scale","typeGuard":"def is_valid_scale(v) -> bool:\n    return isinstance(v, (int, float)) and 0.1 <= v <= 2.0","tryCatchPattern":"try:\n    print_options.scale = scale\nexcept ValueError:\n    print_options.scale = 1.0  # default","preventionTips":["Remember scale is a multiplier in 0.1–2.0, not a percentage.","Clamp external input to the range before assigning."],"tags":["print","scale","validation","range"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}