diff --git a/examples/ruby/spec/bidi/logging_spec.rb b/examples/ruby/spec/bidi/logging_spec.rb index b07b93342628..df010daae8e3 100644 --- a/examples/ruby/spec/bidi/logging_spec.rb +++ b/examples/ruby/spec/bidi/logging_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe 'Logging' do diff --git a/examples/ruby/spec/browsers/chrome/options/arguments_spec.rb b/examples/ruby/spec/browsers/chrome/options/arguments_spec.rb new file mode 100644 index 000000000000..a9ed66dbdcb4 --- /dev/null +++ b/examples/ruby/spec/browsers/chrome/options/arguments_spec.rb @@ -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 diff --git a/examples/ruby/spec/browsers/chrome/options/basic_spec.rb b/examples/ruby/spec/browsers/chrome/options/basic_spec.rb new file mode 100644 index 000000000000..db19fb819317 --- /dev/null +++ b/examples/ruby/spec/browsers/chrome/options/basic_spec.rb @@ -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 diff --git a/examples/ruby/spec/browsers/chrome/options/binary_spec.rb b/examples/ruby/spec/browsers/chrome/options/binary_spec.rb new file mode 100644 index 000000000000..870f0e7cf801 --- /dev/null +++ b/examples/ruby/spec/browsers/chrome/options/binary_spec.rb @@ -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 diff --git a/examples/ruby/spec/browsers/chrome/options/detach_spec.rb b/examples/ruby/spec/browsers/chrome/options/detach_spec.rb new file mode 100644 index 000000000000..d3d3c2779625 --- /dev/null +++ b/examples/ruby/spec/browsers/chrome/options/detach_spec.rb @@ -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 diff --git a/examples/ruby/spec/browsers/chrome/options/exclude_switches_spec.rb b/examples/ruby/spec/browsers/chrome/options/exclude_switches_spec.rb new file mode 100644 index 000000000000..c6f85a83618f --- /dev/null +++ b/examples/ruby/spec/browsers/chrome/options/exclude_switches_spec.rb @@ -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 diff --git a/examples/ruby/spec/browsers/chrome/options/extensions_spec.rb b/examples/ruby/spec/browsers/chrome/options/extensions_spec.rb new file mode 100644 index 000000000000..fa21474c8fa6 --- /dev/null +++ b/examples/ruby/spec/browsers/chrome/options/extensions_spec.rb @@ -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 diff --git a/examples/ruby/spec/getting_started/using_selenium_spec.rb b/examples/ruby/spec/getting_started/using_selenium_spec.rb index f972389fca0b..0019c64bc210 100644 --- a/examples/ruby/spec/getting_started/using_selenium_spec.rb +++ b/examples/ruby/spec/getting_started/using_selenium_spec.rb @@ -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 diff --git a/examples/ruby/spec/spec_helper.rb b/examples/ruby/spec/spec_helper.rb index a68a4526f0be..80cc91c61522 100644 --- a/examples/ruby/spec/spec_helper.rb +++ b/examples/ruby/spec/spec_helper.rb @@ -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 diff --git a/website_and_docs/content/documentation/webdriver/bidi/logging.en.md b/website_and_docs/content/documentation/webdriver/bidi/logging.en.md index 312123ec9737..8817ed9ff209 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/logging.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/logging.en.md @@ -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 >}} @@ -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 >}} @@ -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 >}} @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/logging.ja.md b/website_and_docs/content/documentation/webdriver/bidi/logging.ja.md index ae23c7a6412b..77d1995aa327 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/logging.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/logging.ja.md @@ -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 >}} @@ -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 >}} @@ -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 >}} @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/logging.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/logging.pt-br.md index 8109898135fd..402ea5f5e214 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/logging.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/logging.pt-br.md @@ -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 >}} @@ -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 >}} @@ -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 >}} @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/logging.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/logging.zh-cn.md index 8109898135fd..402ea5f5e214 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/logging.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/logging.zh-cn.md @@ -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 >}} @@ -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 >}} @@ -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 >}} @@ -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 >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md index 224c8bcbd3b5..65dc3081aaea 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md @@ -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">}} @@ -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">}} @@ -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">}} @@ -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">}} @@ -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">}} @@ -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">}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md index f2641c0136b7..c9024642d85e 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md @@ -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" >}} @@ -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" >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md index e69f82b69732..01eeedf03c1d 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md @@ -141,7 +141,7 @@ Seleniumコードの使用方法に関係なく、優れた統合開発環境が {{< 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" >}} @@ -184,11 +184,11 @@ Seleniumコードの使用方法に関係なく、優れた統合開発環境が ### 並べる -{{< 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" >}} ### 取り壊す -{{< 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" >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md index 8281f5211e32..362e63cfac58 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md @@ -146,7 +146,7 @@ In your project's `package.json`, adicionar requisito às `dependências`: {{< 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" >}} @@ -188,11 +188,11 @@ In your project's `package.json`, adicionar requisito às `dependências`: ### 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" >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md index eb0e813823d4..977c7e9c8fa8 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.zh-cn.md @@ -130,7 +130,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" >}} @@ -172,11 +172,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" >}} diff --git a/website_and_docs/layouts/shortcodes/gh-codeblock.html b/website_and_docs/layouts/shortcodes/gh-codeblock.html index ca3073301620..ad4209ced0d5 100644 --- a/website_and_docs/layouts/shortcodes/gh-codeblock.html +++ b/website_and_docs/layouts/shortcodes/gh-codeblock.html @@ -21,6 +21,7 @@ {{ $fullPath := .Get "path" }} {{ $path := index (split $fullPath "#") 0 }} +{{ $hasFragment := in $fullPath "#" }} {{ $apiUrl := printf "%s/%s/%s/contents%s?ref=%s" $apiBaseUrl $org $repo $path $branch }} {{ $webUrl := printf "%s/%s/%s/blob/%s/%s" $webBaseUrl $org $repo $branch $fullPath }} @@ -38,26 +39,34 @@ {{ $content := base64Decode $apiResults.content }} {{ $codeSnippet := $content }} - {{ $parsedApiUrl := urls.Parse $webUrl }} - {{ with $parsedApiUrl.Fragment }} - {{ $codeLines := split $parsedApiUrl.Fragment "-" }} - {{ $fromLine := sub (int (replace (index $codeLines 0) "L" "")) 1 }} - {{ $toLine := int (cond (eq (len $codeLines) 1) (replace (index $codeLines 0) "L" "") (replace (index $codeLines 1) "L" "")) }} - {{ $numOfLines := cond (eq (sub $toLine $fromLine) 0) 1 (sub $toLine $fromLine) }} - {{ $splitContent := split $content "\n" }} - {{ $codeSnippet = delimit (first $numOfLines (after $fromLine $splitContent)) "\n" }} - {{ end }} - - {{ highlight $codeSnippet $language }} - -