Skip to content

Commit

Permalink
Add all special features examples for edge using ruby (#1740)[deploy …
Browse files Browse the repository at this point in the history
…site]

Co-authored-by: aguspe <agustin.pe94@gmail.com>
  • Loading branch information
aguspe and Pexpe committed May 25, 2024
1 parent f50ca21 commit c56ec04
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 16 deletions.
46 changes: 46 additions & 0 deletions examples/ruby/spec/browsers/edge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,57 @@
end
end

describe 'Special Features' do
it 'casts' do
@driver = Selenium::WebDriver.for :edge
sinks = @driver.cast_sinks
unless sinks.empty?
device_name = sinks.first['name']
@driver.start_cast_tab_mirroring(device_name)
expect { @driver.stop_casting(device_name) }.not_to raise_exception
end
end

it 'gets and sets network conditions' do
@driver = Selenium::WebDriver.for :edge
@driver.network_conditions = {offline: false, latency: 100, throughput: 200}
expect(@driver.network_conditions).to eq(
'offline' => false,
'latency' => 100,
'download_throughput' => 200,
'upload_throughput' => 200)
end

it 'gets the browser logs' do
@driver = Selenium::WebDriver.for :edge
@driver.navigate.to 'https://www.selenium.dev/selenium/web/'
sleep 1
logs = @driver.logs.get(:browser)

expect(logs.first.message).to include 'Failed to load resource'
end

it 'sets permissions' do
@driver = Selenium::WebDriver.for :edge
@driver.navigate.to 'https://www.selenium.dev/selenium/web/'
@driver.add_permission('camera', 'denied')
@driver.add_permissions('clipboard-read' => 'denied', 'clipboard-write' => 'prompt')
expect(permission('camera')).to eq('denied')
expect(permission('clipboard-read')).to eq('denied')
expect(permission('clipboard-write')).to eq('prompt')
end
end

def driver_finder
options = Selenium::WebDriver::Options.edge(browser_version: 'stable')
service = Selenium::WebDriver::Service.edge
finder = Selenium::WebDriver::DriverFinder.new(options, service)
ENV['EDGEDRIVER_BIN'] = finder.driver_path
ENV['EDGE_BIN'] = finder.browser_path
end

def permission(name)
@driver.execute_async_script('callback = arguments[arguments.length - 1];' \
'callback(navigator.permissions.query({name: arguments[0]}));', name)['state']
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ You can drive Chrome Cast devices with Edge, including sharing tabs
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L119-L123" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -405,7 +405,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L129" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -428,7 +428,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -451,7 +451,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ You can drive Chrome Cast devices with Edge, including sharing tabs
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L119-L123" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -407,7 +407,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L129" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -430,7 +430,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -453,7 +453,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ You can drive Chrome Cast devices with Edge, including sharing tabs
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L119-L123" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -407,7 +407,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L129" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -430,7 +430,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -453,7 +453,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ You can drive Chrome Cast devices with Edge, including sharing tabs
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L119-L123" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -407,7 +407,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L129" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -430,7 +430,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -453,7 +453,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/edge_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down

0 comments on commit c56ec04

Please sign in to comment.