Skip to content

Try optionally displaying the full file #2273

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

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 2 additions & 0 deletions examples/ruby/spec/bidi/logging_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Logging' do
Expand Down
13 changes: 13 additions & 0 deletions examples/ruby/spec/browsers/chrome/options/arguments_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Chrome Options' do
it 'add arguments' do
options = default_chrome_options

options.args << '--start-maximized'

@driver = Selenium::WebDriver.for :chrome, options: options
end
end
10 changes: 10 additions & 0 deletions examples/ruby/spec/browsers/chrome/options/basic_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Chrome Options' do
it 'start session with basic options' do
options = Selenium::WebDriver::Chrome::Options.new
@driver = Selenium::WebDriver.for :chrome, options: options
end
end
23 changes: 23 additions & 0 deletions examples/ruby/spec/browsers/chrome/options/binary_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Chrome Options' do
it 'sets location of binary' do
options = default_chrome_options

options.binary = chrome_location

@driver = Selenium::WebDriver.for :chrome, options: options
end

private

def chrome_location
options = default_chrome_options
service = Selenium::WebDriver::Service.chrome
finder = Selenium::WebDriver::DriverFinder.new(options, service)
ENV['CHROMEDRIVER_BIN'] = finder.driver_path
ENV['CHROME_BIN'] = finder.browser_path
end
end
13 changes: 13 additions & 0 deletions examples/ruby/spec/browsers/chrome/options/detach_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Chrome Options' do
it 'keeps browser open' do
options = default_chrome_options

options.detach = true

@driver = Selenium::WebDriver.for :chrome, options: options
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Chrome Options' do
it 'excludes switches' do
options = default_chrome_options

options.exclude_switches << 'disable-popup-blocking'

@driver = Selenium::WebDriver.for :chrome, options: options
end
end
18 changes: 18 additions & 0 deletions examples/ruby/spec/browsers/chrome/options/extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Chrome Options' do
it 'add extensions' do
options = default_chrome_options

extension_file_path = File.expand_path('../../../spec_support/extensions/webextensions-selenium-example.crx',
__dir__)
options.add_extension(extension_file_path)

@driver = Selenium::WebDriver.for :chrome, options: options
@driver.get('https://www.selenium.dev/selenium/web/blank.html')
injected = @driver.find_element(:id, 'webextensions-selenium-example')
expect(injected.text).to eq 'Content injected by webextensions-selenium-example'
end
end
21 changes: 10 additions & 11 deletions examples/ruby/spec/getting_started/using_selenium_spec.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
# frozen_string_literal: true

require 'spec_helper'
require 'selenium-webdriver'

RSpec.describe 'Using Selenium' do
before do
@driver = Selenium::WebDriver.for :chrome
end

it 'uses eight components' do
@driver.get('https://www.selenium.dev/selenium/web/web-form.html')
driver = Selenium::WebDriver.for :chrome

title = @driver.title
driver.get('https://www.selenium.dev/selenium/web/web-form.html')

title = driver.title
expect(title).to eq('Web form')

@driver.manage.timeouts.implicit_wait = 500
driver.manage.timeouts.implicit_wait = 500

text_box = @driver.find_element(name: 'my-text')
submit_button = @driver.find_element(tag_name: 'button')
text_box = driver.find_element(name: 'my-text')
submit_button = driver.find_element(tag_name: 'button')

text_box.send_keys('Selenium')
submit_button.click

message = @driver.find_element(id: 'message')
message = driver.find_element(id: 'message')
value = message.text
expect(value).to eq('Received!')

driver.quit
end
end
19 changes: 14 additions & 5 deletions examples/ruby/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,28 @@
config.after { @driver&.quit }

def start_session
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('disable-search-engine-choice-screen')
options.add_argument('--no-sandbox')
@driver = Selenium::WebDriver.for(:chrome, options: options)
@service = Selenium::WebDriver::Service.chrome
@driver = Selenium::WebDriver.for :chrome, options: default_chrome_options
end

def start_bidi_session
options = Selenium::WebDriver::Chrome::Options.new(web_socket_url: true)
options = default_chrome_options
options.web_socket_url = true
@driver = Selenium::WebDriver.for :chrome, options: options
end

def default_chrome_options
options = Selenium::WebDriver::Chrome::Options.new
options.browser_version = 'stable'
options.timeouts = {implicit: 500}
options.add_argument('disable-search-engine-choice-screen')
options.add_argument('--no-sandbox') if Selenium::WebDriver::Platform.os == :linux
options
end

def start_firefox
options = Selenium::WebDriver::Options.firefox(timeouts: {implicit: 1500})
options.browser_version = 'stable'
@driver = Selenium::WebDriver.for :firefox, options: options
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Record or take actions on `console.log` events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L11" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L13" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -56,7 +56,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L22-L23" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L24-L25" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -83,7 +83,7 @@ Record or take actions on JavaScript exception events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L33" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L35" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -108,7 +108,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L44-L45" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L46-L47" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Record or take actions on `console.log` events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L11" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L13" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -56,7 +56,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L22-L23" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L24-L25" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -83,7 +83,7 @@ Record or take actions on JavaScript exception events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L33" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L35" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -108,7 +108,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L44-L45" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L46-L47" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Record or take actions on `console.log` events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L11" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L13" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -56,7 +56,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L22-L23" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L24-L25" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -83,7 +83,7 @@ Record or take actions on JavaScript exception events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L33" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L35" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -108,7 +108,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L44-L45" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L46-L47" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Record or take actions on `console.log` events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L11" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L13" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -56,7 +56,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L22-L23" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L24-L25" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -83,7 +83,7 @@ Record or take actions on JavaScript exception events.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L33" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L35" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand All @@ -108,7 +108,7 @@ You need to store the ID returned when adding the handler to delete it.
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L44-L45" >}}
{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L46-L47" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-implementation >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Starting a Chrome session with basic defined options looks like this:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs#L30-L31" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L10-L11" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome/options/basic_spec.rb#L7-L8" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/browser/chromeSpecificCaps.spec.js#L51-L55">}}
Expand Down Expand Up @@ -64,7 +64,7 @@ Add an argument to options:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs#L39" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L17" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome/options/arguments_spec.rb#L9" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/browser/chromeSpecificCaps.spec.js#L9-L12">}}
Expand Down Expand Up @@ -92,7 +92,7 @@ Add a browser location to options:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs#L49" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L25" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome/options/binary_spec.rb#L9" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/browser/chromeSpecificCaps.spec.js#L41-L44">}}
Expand Down Expand Up @@ -121,7 +121,7 @@ Add an extension to options:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs#L61" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L34" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome/options/extensions_spec.rb#L10" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/browser/chromeSpecificCaps.spec.js#L62-L66">}}
Expand All @@ -147,7 +147,7 @@ so long as the quit command is not sent to the driver.
**Note**: This is already the default behavior in .NET.
{{% /tab %}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L45" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome/options/detach_spec.rb#L9" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/browser/chromeSpecificCaps.spec.js#L29-L32">}}
Expand Down Expand Up @@ -178,7 +178,7 @@ Set excluded arguments on options:
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs#L76" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L53" >}}
{{< gh-codeblock path="/examples/ruby/spec/browsers/chrome/options/exclude_switches_spec.rb#L9" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/browser/chromeSpecificCaps.spec.js#L19-L22">}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ In your project's `package.json`, add requirement to `dependencies`:
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/GettingStarted/UsingSeleniumTest.cs#L19-L20" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb#L14-L15" >}}
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb#L11-L12" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="examples/javascript/test/getting_started/runningTests.spec.js#L14-L15" >}}
Expand Down Expand Up @@ -194,11 +194,11 @@ In your project's `package.json`, add requirement to `dependencies`:

### Set Up

{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb#L7-L9" >}}
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb#L7" >}}

### Tear Down

{{< gh-codeblock path="examples/ruby/spec/spec_helper.rb#L30" >}}
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb#L26" >}}
{{% /tab %}}
{{< tab header="JavaScript" >}}

Expand Down
Loading
Loading