File tree Expand file tree Collapse file tree 5 files changed +23
-2
lines changed Expand file tree Collapse file tree 5 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -705,6 +705,12 @@ browser.evaluate("window.__injected") # => 42
705
705
#### frames
706
706
#### main_frame
707
707
#### frame_by
708
+ #### set_content(html)
709
+
710
+ Sets a content of given frame
711
+
712
+ * html ` String `
713
+
708
714
709
715
Play around inside given frame
710
716
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Browser
17
17
delegate %i[ default_context ] => :contexts
18
18
delegate %i[ targets create_target create_page page pages windows ] => :default_context
19
19
delegate %i[ goto back forward refresh reload stop
20
- at_css at_xpath css xpath current_url title body doctype
20
+ at_css at_xpath css xpath current_url title body doctype set_content
21
21
headers cookies network
22
22
mouse keyboard
23
23
screenshot pdf viewport_size
Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ def main?
35
35
@parent_id . nil?
36
36
end
37
37
38
+ def set_content ( html )
39
+ evaluate_async ( %(
40
+ document.open();
41
+ document.write(arguments[0]);
42
+ document.close();
43
+ arguments[1](true);
44
+ ) , @page . timeout , html )
45
+ end
46
+
38
47
def execution_id? ( execution_id )
39
48
@execution_id == execution_id
40
49
end
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def reset
31
31
32
32
extend Forwardable
33
33
delegate %i[ at_css at_xpath css xpath
34
- current_url current_title url title body doctype
34
+ current_url current_title url title body doctype set_content
35
35
execution_id evaluate evaluate_on evaluate_async execute
36
36
add_script_tag add_style_tag ] => :main_frame
37
37
Original file line number Diff line number Diff line change @@ -235,6 +235,12 @@ module Ferrum
235
235
expect ( frame . url ) . to end_with ( "/ferrum/slow" )
236
236
expect ( browser . current_url ) . to end_with ( "/ferrum/frames" )
237
237
end
238
+
239
+ it "can set page content" do
240
+ browser . set_content ( %(<html><head></head><body>Voila!</body></html>) )
241
+
242
+ expect ( browser . body ) . to include ( "Voila!" )
243
+ end
238
244
end
239
245
end
240
246
end
You can’t perform that action at this time.
0 commit comments