Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

816
Visualizações
How to setup Selenium Webdriver, Capybara, and Rails Minitest?

I am currently running WSL2. I have installed google-chrome-stable and chromedriver in the system.

google-chrome-stable: Google Chrome 92.0.4515.131

chromedriver: ChromeDriver 92.0.4515.43

# Gemfile

group :test do
  gem "capybara", ">= 3.26"
  gem "selenium-webdriver"
  gem "webdrivers"
end
# test/application_system_test_case.rb

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :headless_chrome do |option|
    option.add_argument "no-sandbox"
  end
end
# test/system/users_test.rb

class UsersTest < ApplicationSystemTestCase
  def setup
    Capybara.app_host = "http://app.example.com/"
  end

  test "user sign up" do
    visit new_user_path
    fill_in "user[name]", with: "Jane Hemmingway"
    fill_in "user[email]", with: "jane@example.com"
    fill_in "user[password]", with: "secret_password"
    click_button "get started"

    assert_redirected_to accounts_path
  end
end

But when I run this test, it throws an error.

Error:
UsersTest#test_user_sign_up:
Selenium::WebDriver::Error::UnknownError: unknown error: net::ERR_NAME_NOT_RESOLVED
  (Session info: headless chrome=92.0.4515.131)
    test/system/users_test.rb:9:in `block in <class:UsersTest>'

I'm confused about what this error means. Is there a way I can fix it?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Ok, so instead of setting Capybara.app_host as http://app.example.com/, we need to set it to http://app.lvh.me.

We also need to tell capybara to always include the port.

# test/application_system_test_case.rb

Capybara.configure do |config|
  config.always_include_port = true
end

Now the tests runs as expected.

over 4 years ago · Santiago Trujillo Relatório

0

The error net::ERR_NAME_NOT_RESOLVED is telling you what the problem is. www.example.com isn't resolving to an ip address on whatever machine the browser is being launched on.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda