Skip to content

Add permissions examples and update the log examples #1731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions examples/ruby/spec/browsers/chrome_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,25 @@
'download_throughput' => 200,
'upload_throughput' => 200)
end
end

it 'gets the browser logs' do
@driver = Selenium::WebDriver.for :chrome
@driver.navigate.to 'https://www.selenium.dev/selenium/web/'
sleep 1
logs = @driver.logs.get(:browser)
it 'gets the browser logs' do
@driver = Selenium::WebDriver.for :chrome
@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

expect(logs.first.message).to include 'Failed to load resource'
it 'sets permissions' do
@driver = Selenium::WebDriver.for :chrome
@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
Expand All @@ -151,4 +161,9 @@ def driver_finder
ENV['CHROMEDRIVER_BIN'] = finder.driver_path
ENV['CHROME_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 @@ -428,7 +428,7 @@ You can simulate various network conditions.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L142" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_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/chrome_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ please refer to the
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L142" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -457,7 +457,7 @@ please refer to the
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ please refer to the
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L142" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -454,7 +454,7 @@ please refer to the
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ please refer to the
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L142" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L141" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -453,7 +453,7 @@ please refer to the
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L149-L150" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
Loading