I have the following code and i want to create a user Directory with the name 'mydir' where chrome should output console logs, but wat happens is it creates a directory #{dir} instead. I also tried using CONST Variables still the same result. Can some help me out?
require "selenium-webdriver"
class MyClass
dir='mydir'
@driver = Selenium::WebDriver.for :chrome, :switches => %w[--ignore-certificate-errors --user-data-dir=#{dir} --enable-logging]
end
The
%w
literal is similar to using single quotes for Strings. There is no interpolation. As a result, the--user-data-dir
is exactly what was typed - "#{dir}". To enable interpolation, you need to use a capital W - ie%W
:You can see the difference with:
In the end, your script would become: