-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Rails 7.1.2 system tests won't find Chrome downloaded by selenium-webdriver #50287
Comments
Could this be the problem? When preloading, we use the existing namespace::Service.driver_path = ::Selenium::WebDriver::DriverFinder.path(
options || namespace::Options.new, # <-- throwaway object
namespace::Service
) Therefore, if If this is indeed the problem, then a solution would be to force def resolve_driver_path(namespace)
initialize_options
namespace::Service.driver_path = ::Selenium::WebDriver::DriverFinder.path(
options, # <-- mutations are now retained
namespace::Service
)
end That said, I don't really understand why |
Yeah, that seems to work. When I was exploring this, I wasn't sure if the I've tried to figure out if there's any clear reason to lazy-initialize the options value. If I move the call to |
That was my conclusion as well.
I believe you are correct. There doesn't seem to be a reason for that assertion. I think it is asserting incidental behavior from f52e17f, not expected behavior. Likewise, there doesn't seem to be a clear reason for a separate So I have submitted #50296 to address this issue and clean up the code a bit. |
With a recent change (#49908), if you don't have the Chrome (or Chromium) browser accessible in your default system path, system tests will fail to run.
It's not necessary to have Chrome installed to use Selenium with Chrome, because the
chromedriver
binary will automatically download a version and store it in a cache directory for you.I believe this error is caused by the assignment to
namespace::Service.driver_path
:Internally within selenium-webdriver, if this value is assigned, some important behaviour is skipped when this code runs within
selenium-webdriver
:One side-effect of the
SeleniumManager.driver_path(options)
method call is that the location of any Chrome binary is inserted into theoptions
Hash, which is then used in other parts of the system and ultimately sent as part of the "capabilities" to thechromedriver
process.However, if
klass.driver_path
is already set -- which is what the change in #49908 does -- then thebegin .. end
block is not evaluated, and so the location of any Chrome binary that selenium-webdrivers finds is never inserted into theoptions
Hash.In my script below I've enabled debug logging from selenium-webdriver, and within the logging, you'll see this:
If I disable the change made in #49908 (e.g. by uncommenting the part of the script below that changes the
preload
method into a no-op), you'll see this in the logging instead:Crucially, the "binary" value is present, which tells
chromedriver
how to actually launch the specific instance of Chrome that the gem has downloaded on our behalf.Steps to reproduce
Most importantly, you must not have Chrome or Chromium installed via any other mechanism.
This script is sufficient to replicate the issue for me:
Expected behavior
The test should run without any errors.
Actual behavior
An exception is raised:
System configuration
Rails version: 7.1.2, edge
Ruby version: 3.2.2
Chrome version: importantly, not installed!
The text was updated successfully, but these errors were encountered: