16
16
# KIND, either express or implied. See the License for the
17
17
# specific language governing permissions and limitations
18
18
# under the License.
19
+ require_relative 'network/url_pattern'
19
20
20
21
module Selenium
21
22
module WebDriver
@@ -39,8 +40,12 @@ def initialize(bidi)
39
40
@bidi = bidi
40
41
end
41
42
42
- def add_intercept ( phases : [ ] , contexts : nil , url_patterns : nil )
43
- @bidi . send_cmd ( 'network.addIntercept' , phases : phases , contexts : contexts , urlPatterns : url_patterns )
43
+ def add_intercept ( phases : [ ] , contexts : nil , url_patterns : nil , pattern_type : :string )
44
+ url_patterns = url_patterns && pattern_type ? UrlPattern . format_pattern ( url_patterns , pattern_type ) : nil
45
+ @bidi . send_cmd ( 'network.addIntercept' ,
46
+ phases : phases ,
47
+ contexts : contexts ,
48
+ urlPatterns : url_patterns )
44
49
end
45
50
46
51
def remove_intercept ( intercept )
@@ -50,31 +55,67 @@ def remove_intercept(intercept)
50
55
def continue_with_auth ( request_id , username , password )
51
56
@bidi . send_cmd (
52
57
'network.continueWithAuth' ,
53
- ' request' => request_id ,
54
- ' action' => 'provideCredentials' ,
55
- ' credentials' => {
56
- ' type' => 'password' ,
57
- ' username' => username ,
58
- ' password' => password
58
+ request : request_id ,
59
+ action : 'provideCredentials' ,
60
+ credentials : {
61
+ type : 'password' ,
62
+ username : username ,
63
+ password : password
59
64
}
60
65
)
61
66
end
62
67
63
- def continue_with_request ( ** args )
68
+ def continue_without_auth ( request_id )
64
69
@bidi . send_cmd (
65
- 'network.continueWithRequest' ,
66
- request : args [ :request_id ] ,
67
- 'body' => args [ :body ] ,
68
- 'cookies' => args [ :cookies ] ,
69
- 'headers' => args [ :headers ] ,
70
- 'method' => args [ :method ] ,
71
- 'url' => args [ :url ]
70
+ 'network.continueWithAuth' ,
71
+ request : request_id ,
72
+ action : 'default'
73
+ )
74
+ end
75
+
76
+ def cancel_auth ( request_id )
77
+ @bidi . send_cmd (
78
+ 'network.continueWithAuth' ,
79
+ request : request_id ,
80
+ action : 'cancel'
81
+ )
82
+ end
83
+
84
+ def continue_request ( **args )
85
+ @bidi . send_cmd (
86
+ 'network.continueRequest' ,
87
+ request : args [ :id ] ,
88
+ body : args [ :body ] ,
89
+ cookies : args [ :cookies ] ,
90
+ headers : args [ :headers ] ,
91
+ method : args [ :method ] ,
92
+ url : args [ :url ]
93
+ )
94
+ end
95
+
96
+ def fail_request ( request_id )
97
+ @bidi . send_cmd (
98
+ 'network.failRequest' ,
99
+ request : request_id
100
+ )
101
+ end
102
+
103
+ def continue_response ( **args )
104
+ @bidi . send_cmd (
105
+ 'network.continueResponse' ,
106
+ request : args [ :id ] ,
107
+ cookies : args [ :cookies ] ,
108
+ credentials : args [ :credentials ] ,
109
+ headers : args [ :headers ] ,
110
+ reasonPhrase : args [ :reason ] ,
111
+ statusCode : args [ :status ]
72
112
)
73
113
end
74
114
75
115
def on ( event , &)
76
116
event = EVENTS [ event ] if event . is_a? ( Symbol )
77
117
@bidi . add_callback ( event , &)
118
+ @bidi . session . subscribe ( event )
78
119
end
79
120
end # Network
80
121
end # BiDi
0 commit comments