Skip to content

Commit

Permalink
fix ruby linting issues (#1380)
Browse files Browse the repository at this point in the history
* fix ruby linting issues

* change timeouts in wait examples from 1 second to 2

[deploy site]
  • Loading branch information
titusfortner committed May 9, 2023
1 parent f9c6d90 commit a6b704a
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.0
bundler-cache: true
- name: Install Gems
working-directory: ./examples/ruby
Expand Down
6 changes: 3 additions & 3 deletions examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Sleep()
[TestMethod]
public void Implicit()
{
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);

driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html";
driver.FindElement(By.Id("adder")).Click();
Expand All @@ -51,7 +51,7 @@ public void Explicit()
{
driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html";
IWebElement revealed = driver.FindElement(By.Id("revealed"));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(1));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2));

driver.FindElement(By.Id("reveal")).Click();
wait.Until(d => revealed.Displayed);
Expand All @@ -65,7 +65,7 @@ public void ExplicitOptions()
{
driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html";
IWebElement revealed = driver.FindElement(By.Id("revealed"));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(1))
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2))
{
PollingInterval = TimeSpan.FromMilliseconds(300),
};
Expand Down
6 changes: 3 additions & 3 deletions examples/java/src/test/java/dev/selenium/waits/WaitsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void sleep() throws InterruptedException {

@Test
public void implicit() {
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(2));
driver.get("https://www.selenium.dev/selenium/web/dynamic.html");
driver.findElement(By.id("adder")).click();

Expand All @@ -55,7 +55,7 @@ public void implicit() {
public void explicit() {
driver.get("https://www.selenium.dev/selenium/web/dynamic.html");
WebElement revealed = driver.findElement(By.id("revealed"));
Wait<WebDriver> wait = new WebDriverWait(driver, Duration.ofSeconds(1));
Wait<WebDriver> wait = new WebDriverWait(driver, Duration.ofSeconds(2));

driver.findElement(By.id("reveal")).click();
wait.until(d -> revealed.isDisplayed());
Expand All @@ -69,7 +69,7 @@ public void explicitWithOptions() {
driver.get("https://www.selenium.dev/selenium/web/dynamic.html");
WebElement revealed = driver.findElement(By.id("revealed"));
Wait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(1))
.withTimeout(Duration.ofSeconds(2))
.pollingEvery(Duration.ofMillis(300))
.ignoring(ElementNotInteractableException.class);

Expand Down
4 changes: 2 additions & 2 deletions examples/python/tests/waits/test_waits.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def test_sleep(driver):
driver.get('https://www.selenium.dev/selenium/web/dynamic.html')
driver.find_element(By.ID, "adder").click()

time.sleep(1)
time.sleep(2)
added = driver.find_element(By.ID, "box0")

assert added.get_dom_attribute('class') == "redbox"


def test_implicit(driver):
driver.implicitly_wait(1)
driver.implicitly_wait(2)
driver.get('https://www.selenium.dev/selenium/web/dynamic.html')
driver.find_element(By.ID, "adder").click()

Expand Down
2 changes: 1 addition & 1 deletion examples/ruby/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.7.0
TargetRubyVersion: 3.0
NewCops: enable
SuggestExtensions:
rubocop-rake: false
Expand Down
6 changes: 6 additions & 0 deletions examples/ruby/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ AllCops:
- 'spec/virtual_authenticator/virtual_authenticator_spec.rb'
- 'spec/hello/hello_selenium_spec.rb'
- 'spec/getting_started/open_browser_spec.rb'

RSpec/NoExpectationExample:
Enabled: false

RSpec/InstanceVariable:
Enabled: false
4 changes: 2 additions & 2 deletions examples/ruby/spec/actions_api/mouse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
.perform

rect = mouse_tracker.rect
center_x = rect.width/2
center_y = rect.height/2
center_x = rect.width / 2
center_y = rect.height / 2
x_coord, y_coord = driver.find_element(id: 'relative-location').text.split(',').map(&:to_i)

expect(x_coord).to be_within(1).of(center_x + 8)
Expand Down
2 changes: 1 addition & 1 deletion examples/ruby/spec/browsers/edge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
@driver = Selenium::WebDriver.for :edge, options: options
@driver.get('https://www.google.com')
end
end
end
7 changes: 3 additions & 4 deletions examples/ruby/spec/support/select_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'spec_helper'

RSpec.describe 'Chrome' do

let(:driver) { start_session }

before do
Expand All @@ -18,13 +17,13 @@
four_element = driver.find_element(css: 'option[value=four]')
count_element = driver.find_element(css: "option[value='still learning how to count, apparently']")

select.select_by(:text,'Four')
select.select_by(:text, 'Four')
expect(four_element).to be_selected

select.select_by(:value,'two')
select.select_by(:value, 'two')
expect(two_element).to be_selected

select.select_by(:index,3)
select.select_by(:index, 3)
expect(count_element).to be_selected
end

Expand Down
4 changes: 2 additions & 2 deletions examples/ruby/spec/waits/waits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

it 'implicit' do
driver.manage.timeouts.implicit_wait = 1
driver.manage.timeouts.implicit_wait = 2
driver.get 'https://www.selenium.dev/selenium/web/dynamic.html'
driver.find_element(id: 'adder').click

Expand All @@ -51,7 +51,7 @@
revealed = driver.find_element(id: 'revealed')
errors = [Selenium::WebDriver::Error::NoSuchElementError,
Selenium::WebDriver::Error::ElementNotInteractableError]
wait = Selenium::WebDriver::Wait.new(timeout: 1,
wait = Selenium::WebDriver::Wait.new(timeout: 2,
interval: 0.3,
ignore: errors)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Note that as of Selenium 4.5, you can't create a `Select` object if the `<select
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L23-L24" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L14-L15" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L13-L14" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L18-L19" >}}
Expand Down Expand Up @@ -98,7 +98,7 @@ Get a list of all options in the `<select>` element:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L52" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L41" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L40" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L45" >}}
Expand All @@ -125,7 +125,7 @@ zero or many elements.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L56" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L44" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L43" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L51" >}}
Expand Down Expand Up @@ -156,7 +156,7 @@ Select the option based on its visible text
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L30" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L21" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L20" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L25" >}}
Expand All @@ -181,7 +181,7 @@ Select the option based on its value attribute
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L33" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L24" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L23" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L28" >}}
Expand All @@ -206,7 +206,7 @@ Select the option based on its position in the list
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L36" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L27" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L26" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L31" >}}
Expand Down Expand Up @@ -240,7 +240,7 @@ Options with a `disabled` attribute may not be selected.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L77" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L63-L65" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L62-L64" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L73-L76" >}}
Expand All @@ -266,7 +266,7 @@ You can repeat these methods for each element you want to select.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L65" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L53" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L63" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Note that as of Selenium 4.5, you can't create a `Select` object if the `<select
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L23-L24" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L14-L15" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L13-L14" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L18-L19" >}}
Expand Down Expand Up @@ -98,7 +98,7 @@ Get a list of all options in the `<select>` element:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L52" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L41" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L40" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L45" >}}
Expand All @@ -125,7 +125,7 @@ zero or many elements.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L56" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L44" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L43" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L51" >}}
Expand Down Expand Up @@ -156,7 +156,7 @@ Select the option based on its visible text
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L30" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L21" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L20" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L25" >}}
Expand All @@ -181,7 +181,7 @@ Select the option based on its value attribute
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L33" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L24" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L23" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L28" >}}
Expand All @@ -206,7 +206,7 @@ Select the option based on its position in the list
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L36" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L27" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L26" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L31" >}}
Expand Down Expand Up @@ -240,7 +240,7 @@ Options with a `disabled` attribute may not be selected.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L77" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L63-L65" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L62-L64" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L73-L76" >}}
Expand All @@ -266,7 +266,7 @@ You can repeat these methods for each element you want to select.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L65" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L53" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L63" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Note that as of Selenium 4.5, you can't create a `Select` object if the `<select
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L23-L24" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L14-L15" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L13-L14" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L18-L19" >}}
Expand Down Expand Up @@ -99,7 +99,7 @@ Get a list of all options in the `<select>` element:
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L52" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L41" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L40" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L45" >}}
Expand All @@ -126,7 +126,7 @@ zero or many elements.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L56" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L44" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L43" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L51" >}}
Expand Down Expand Up @@ -157,7 +157,7 @@ Select the option based on its visible text
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L30" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L21" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L20" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L25" >}}
Expand All @@ -182,7 +182,7 @@ Select the option based on its value attribute
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L33" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L24" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L23" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L28" >}}
Expand All @@ -207,7 +207,7 @@ Select the option based on its position in the list
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L36" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L27" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L26" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L31" >}}
Expand Down Expand Up @@ -241,7 +241,7 @@ Options with a `disabled` attribute may not be selected.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L77" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L63-L65" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L62-L64" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L73-L76" >}}
Expand All @@ -267,7 +267,7 @@ You can repeat these methods for each element you want to select.
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Support/SelectListTest.cs#L65" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L53" >}}
{{< gh-codeblock path="/examples/ruby/spec/support/select_list_spec.rb#L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="/examples/javascript/test/select/selectListTest.spec.js#L63" >}}
Expand Down
Loading

0 comments on commit a6b704a

Please sign in to comment.