Skip to content

Commit 5e20f5d

Browse files
committed
Support custom and predefined page sizes in PrintOptions; update tests
1 parent 4ca0796 commit 5e20f5d

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

rb/lib/selenium/webdriver/common/print_options.rb

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,7 @@ def to_h
6262
# Gets the current page size.
6363
#
6464
# @return [Hash] The current page size hash with :width and :height.
65-
def page_size
66-
@page_size
67-
end
68-
69-
# Sets the page size. Can be a predefined symbol or custom size hash.
70-
#
71-
# @param [Symbol, Hash] value The predefined size (:letter, :legal, :a4, :tabloid) or a custom hash.
72-
def page_size=(value)
73-
predefined_sizes = {
74-
letter: {width: 21.59, height: 27.94},
75-
legal: {width: 21.59, height: 35.56},
76-
a4: {width: 21.0, height: 29.7},
77-
tabloid: {width: 27.94, height: 43.18}
78-
}
79-
80-
case value
81-
when Symbol
82-
raise ArgumentError, "Invalid page size: #{value}" unless predefined_sizes.key?(value)
83-
84-
@page_size = predefined_sizes[value]
85-
when Hash
86-
unless value.key?(:width) && value.key?(:height)
87-
raise ArgumentError, 'Custom page size must include :width and :height'
88-
end
89-
90-
@page_size = value
91-
else
92-
raise ArgumentError, 'Page size must be a Symbol or a Hash'
93-
end
94-
end
65+
attr_reader :page_size
9566

9667
# Sets the page size. Can be a predefined symbol or custom size hash.
9768
#

0 commit comments

Comments
 (0)