【发布时间】:2020-12-05 04:17:23
【问题描述】:
我正在尝试在 Firefox 上安装一个插件,但是,我尝试过的任何方法都无法实现。
require 'capybara'
require 'selenium-webdriver'
Capybara.register_driver :selenium_proxy do |app|
desired_caps = Selenium::WebDriver::Remote::Capabilities.firefox
options = Selenium::WebDriver::Firefox::Options.new
profile = Selenium::WebDriver::Firefox::Profile.new
# Here is the add-on I am trying to install.
profile.add_extension('/home/user/Downloads/try_xpath-1.3.5-fx.xpi')
options.profile = profile
Capybara::Selenium::Driver.new(app, {
browser: :firefox,
desired_capabilities: desired_caps,
options: options
})
end
browser = Capybara::Session.new(:selenium_proxy)
browser.visit 'https://google.com'
我在这里做错了什么?浏览器在不安装任何插件的情况下访问 URL。我可以从文件中手动安装插件。
此外,当我想添加个人资料时,我收到以下错误:
Errno::ENOENT: No such file or directory @ rb_file_s_stat - /tmp/webdriver-rb-profilecopy20200815-25523-ie6apk/lock
from /home/burak/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubyzip-2.2.0/lib/zip/entry.rb:405:in `stat'
【问题讨论】:
标签: ruby selenium selenium-webdriver capybara