{"record":{"id":"df6f120da165502e","repo":"SeleniumHQ/selenium","slug":"invalid-page-size-value","errorCode":null,"errorMessage":"Invalid page size: #{value}","messagePattern":"Invalid page size: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/print_options.rb","lineNumber":78,"sourceCode":"      # Gets the current page size.\n      #\n      # @return [Hash] The current page size hash with :width and :height.\n      attr_reader :page_size\n\n      # Sets the page size. Can be a predefined symbol or custom size hash.\n      #\n      # @param [Symbol, Hash] value The predefined size (:letter, :legal, :a4, :tabloid) or a custom hash.\n      def page_size=(value)\n        predefined_sizes = {\n          letter: {width: 21.59, height: 27.94},\n          legal: {width: 21.59, height: 35.56},\n          a4: {width: 21.0, height: 29.7},\n          tabloid: {width: 27.94, height: 43.18}\n        }\n\n        case value\n        when Symbol\n          raise ArgumentError, \"Invalid page size: #{value}\" unless predefined_sizes.key?(value)\n\n          @page_size = predefined_sizes[value]\n        when Hash\n          unless value.key?(:width) && value.key?(:height)\n            raise ArgumentError, 'Custom page size must include :width and :height'\n          end\n\n          @page_size = value\n        else\n          raise ArgumentError, 'Page size must be a Symbol or a Hash'\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":60,"sourceCodeEnd":94,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/print_options.rb#L60-L94","documentation":"PrintOptions#page_size= accepts a Symbol naming a predefined paper size (:letter, :legal, :a4, :tabloid). If the Symbol is not one of those keys, ArgumentError is raised. For custom dimensions, pass a Hash with :width and :height instead.","triggerScenarios":"Calling print_options.page_size = :a3 (not predefined). Using an uppercase or misspelled Symbol like :A4 or :leter. Passing a Symbol for a paper size the library does not ship.","commonSituations":"Assuming a paper size is supported when it is not. Case sensitivity mistakes (:A4 vs :a4). Typos in size names.","solutions":["Use one of the predefined Symbols: :letter, :legal, :a4, or :tabloid.","For any other size, pass a custom Hash: page_size = { width: 29.7, height: 42.0 } (cm).","Double-check Symbol casing; the keys are lowercase (:a4, not :A4)."],"exampleFix":"# before\nprint_options.page_size = :a3\n\n# after\nprint_options.page_size = { width: 29.7, height: 42.0 }","handlingStrategy":"validation","validationCode":"allowed = %i[letter legal a4 tabloid]\nraise ArgumentError, \"unsupported size #{size}\" unless allowed.include?(size)","typeGuard":"def predefined_size?(sym)\n  sym.is_a?(Symbol) && %i[letter legal a4 tabloid].include?(sym)\nend","tryCatchPattern":"begin\n  print_options.page_size = size\nrescue ArgumentError => e\n  raise unless e.message.include?('Invalid page size')\n  print_options.page_size = :a4\nend","preventionTips":["Restrict input to the four predefined Symbols or build a custom Hash.","Normalize user input with .to_s.downcase.to_sym and validate.","Document supported sizes for any UI that exposes page_size."],"tags":["ruby","print","page-size","validation"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}