Skip to content

Commit dde1735

Browse files
committed
[rb][bidi] added script module command and types with test
1 parent 592ce73 commit dde1735

File tree

19 files changed

+1695
-6
lines changed

19 files changed

+1695
-6
lines changed

rb/.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ Metrics/ModuleLength:
5959
- 'lib/selenium/webdriver/common/platform.rb'
6060
- 'spec/**/*'
6161

62+
Metrics/ParameterLists:
63+
Enabled: false
64+
6265
Metrics/PerceivedComplexity:
6366
Max: 9
6467
Exclude:
6568
- 'lib/selenium/webdriver/common/local_driver.rb'
6669
- 'lib/selenium/webdriver/common/logger.rb'
70+
- 'lib/selenium/webdriver/bidi/script/protocol_value/remote_value.rb'
6771

6872
Naming/FileName:
6973
Exclude:

rb/lib/selenium/webdriver/bidi.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class BiDi
2323
autoload :Session, 'selenium/webdriver/bidi/session'
2424
autoload :LogInspector, 'selenium/webdriver/bidi/log_inspector'
2525
autoload :BrowsingContext, 'selenium/webdriver/bidi/browsing_context'
26+
autoload :ScriptManager, 'selenium/webdriver/bidi/script_manager'
2627

2728
def initialize(url:)
2829
@ws = WebSocketConnection.new(url: url)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
# frozen_string_literal = true
4+
5+
# Licensed to the Software Freedom Conservancy (SFC) under one
6+
# or more contributor license agreements. See the NOTICE file
7+
# distributed with this work for additional information
8+
# regarding copyright ownership. The SFC licenses this file
9+
# to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance
11+
# with the License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing,
16+
# software distributed under the License is distributed on an
17+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18+
# KIND, either express or implied. See the License for the
19+
# specific language governing permissions and limitations
20+
# under the License.
21+
22+
module Selenium
23+
module WebDriver
24+
class BiDi
25+
class EvaluateResultException
26+
attr_accessor :result_type, :realm_id, :exception_details
27+
28+
def initialize(realm_id, exception_details)
29+
@result_type = EvaluateResultType::EXCEPTION
30+
@realm_id = realm_id
31+
@exception_details = exception_details
32+
end
33+
end
34+
end
35+
end
36+
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
# frozen_string_literal = true
4+
5+
# Licensed to the Software Freedom Conservancy (SFC) under one
6+
# or more contributor license agreements. See the NOTICE file
7+
# distributed with this work for additional information
8+
# regarding copyright ownership. The SFC licenses this file
9+
# to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance
11+
# with the License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing,
16+
# software distributed under the License is distributed on an
17+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18+
# KIND, either express or implied. See the License for the
19+
# specific language governing permissions and limitations
20+
# under the License.
21+
22+
module Selenium
23+
module WebDriver
24+
class BiDi
25+
class EvaluateResultSuccess
26+
attr_accessor :result_type, :realm_id, :result
27+
28+
def initialize(realm_id, value)
29+
@result_type = EvaluateResultType::SUCCESS
30+
@realm_id = realm_id
31+
@result = value
32+
end
33+
end
34+
end
35+
end
36+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
# frozen_string_literal = true
4+
5+
# Licensed to the Software Freedom Conservancy (SFC) under one
6+
# or more contributor license agreements. See the NOTICE file
7+
# distributed with this work for additional information
8+
# regarding copyright ownership. The SFC licenses this file
9+
# to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance
11+
# with the License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing,
16+
# software distributed under the License is distributed on an
17+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18+
# KIND, either express or implied. See the License for the
19+
# specific language governing permissions and limitations
20+
# under the License.
21+
22+
module Selenium
23+
module WebDriver
24+
class BiDi
25+
module EvaluateResultType
26+
SUCCESS = 'success'
27+
EXCEPTION = 'exception'
28+
end
29+
end
30+
end
31+
end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
# frozen_string_literal = true
4+
5+
# Licensed to the Software Freedom Conservancy (SFC) under one
6+
# or more contributor license agreements. See the NOTICE file
7+
# distributed with this work for additional information
8+
# regarding copyright ownership. The SFC licenses this file
9+
# to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance
11+
# with the License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing,
16+
# software distributed under the License is distributed on an
17+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18+
# KIND, either express or implied. See the License for the
19+
# specific language governing permissions and limitations
20+
# under the License.
21+
22+
module Selenium
23+
module WebDriver
24+
class BiDi
25+
class ExceptionDetails
26+
attr_accessor :column_number, :exception, :line_number, :stack_trace, :text
27+
28+
def initialize(exception_details)
29+
@column_number = exception_details.key?('columnNumber') ? exception_details['columnNumber'] : nil
30+
@exception = exception_details.key?('exception') ? exception_details['exception'] : nil
31+
@line_number = exception_details.key?('lineNumber') ? exception_details['lineNumber'] : nil
32+
@stack_trace = exception_details.key?('stackTrace') ? exception_details['stackTrace'] : nil
33+
@text = exception_details.key?('text') ? exception_details['text'] : nil
34+
end
35+
end
36+
end
37+
end
38+
end

rb/lib/selenium/webdriver/bidi/script/non_primitive_type.rb renamed to rb/lib/selenium/webdriver/bidi/script/protocol_type/non_primitive_type.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ module NonPrimitiveType
3030

3131
def self.find_by_name(name)
3232
NonPrimitiveType.constants.each do |type|
33-
return true if name.casecmp(type)
33+
return NonPrimitiveType.const_get(type) if name.casecmp?(NonPrimitiveType.const_get(type))
3434
end
35+
nil
3536
end
3637
end
3738
end

rb/lib/selenium/webdriver/bidi/script/primitive_type.rb renamed to rb/lib/selenium/webdriver/bidi/script/protocol_type/primitive_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ module PrimitiveType
3131

3232
def self.find_by_name(name)
3333
PrimitiveType.constants.each do |type|
34-
return true if name.casecmp(type)
35-
end
34+
return PrimitiveType.const_get(type) if name.casecmp?(PrimitiveType.const_get(type))
35+
end; nil
3636
end
3737
end
3838
end

rb/lib/selenium/webdriver/bidi/script/remote_type.rb renamed to rb/lib/selenium/webdriver/bidi/script/protocol_type/remote_type.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# frozen_string_literal = true
1+
# frozen_string_literal: true
22

33
# Licensed to the Software Freedom Conservancy (SFC) under one
44
# or more contributor license agreements. See the NOTICE file
@@ -39,8 +39,9 @@ module RemoteType
3939

4040
def self.find_by_name(name)
4141
RemoteType.constants.each do |type|
42-
return true if name.casecmp(type)
42+
return RemoteType.const_get(type) if name.casecmp?(RemoteType.const_get(type))
4343
end
44+
nil
4445
end
4546
end
4647
end

rb/lib/selenium/webdriver/bidi/script/special_number_type.rb renamed to rb/lib/selenium/webdriver/bidi/script/protocol_type/special_number_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# frozen_string_literal = true
1+
# frozen_string_literal: true
22

33
# Licensed to the Software Freedom Conservancy (SFC) under one
44
# or more contributor license agreements. See the NOTICE file

0 commit comments

Comments
 (0)