rshf / chromedriver

Automatically exported from code.google.com/p/chromedriver
2 stars 1 forks source link

Chromedriver 2 - Unable to get prefs or extensions working - ruby #806

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Issues with extensions in chromedriver for Ruby. Unable to find a syntax what 
actually loads the CRX extension.

FIRST: Tried to transition to the new chromedriver 2 syntax:
============
Downloaded most recent chromedriver

Copied and pasted the driver start script to test from 
https://code.google.com/p/selenium/wiki/RubyBindings

prefs = {
  :download => {
    :prompt_for_download => false, 
    :default_directory => "/"
  }
}

driver = Selenium::WebDriver.for :chrome, :prefs => prefs

Received the following error:

C:...>client_test3.rb
Starting ChromeDriver (v2.10.267521) on port 52379
Only local connections are allowed.
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.17.0/lib/selenium/webdriv
er/chrome/bridge.rb:64:in `create_capabilities': unknown option: {:prefs=>{:down
load=>{:prompt_for_download=>false, :default_directory=>"/"}}} (ArgumentError)
        from C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.17.0/lib/sel
enium/webdriver/chrome/bridge.rb:20:in `initialize'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.17.0/lib/sel
enium/webdriver/common/driver.rb:37:in `new'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.17.0/lib/sel
enium/webdriver/common/driver.rb:37:in `for'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.17.0/lib/sel
enium/webdriver.rb:60:in `for'
        from C:/GitProjects/_testing/requiredFiles/client_test3.rb:28

============
SECOND: Went back to switches.

Using the following code, Chrome does load. However, the extension does not and 
there is a warning message about a switch being used that isn't in my switches 
at all: 
You are using an unsupported command-line flag: --ignore-certificate-errors. 
Stability and security will suffer.

The extension does not load even though the browser does. 

CODE
========
$RC_browser = :chrome
    capabilities = $RC_browser   #step 5
        if $RC_browser == :chrome
            chrome_switches = %w[--enable-logging --disable-popup-blocking --disable-extensions-file-access-check --always-authorize-plugins --disable-improved-download-protection --allow-file-access --load-extension='C:\GitProjects\_testing\requiredFiles\glazrbeachhead_1.3.8.crx']
            caps_opts = {'chrome.switches' => chrome_switches}
            capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(caps_opts)
            capabilities["browser"] = "chrome"
            capabilities['os'] = 'Windows'
            capabilities['os_version'] = '8.1'
            capabilities['browser_version'] = '34.0.1847.137'
            capabilities['resolution'] = '1280x1024'
            capabilities["browserstack.debug"] = "true"
            capabilities["speed"] = 1
        end
      $driver = Selenium::WebDriver.for(:remote,
                                        :url => $RC_server,
                                        :desired_capabilities => capabilities)

    puts "WebDriver created at https://#{$RC_URL}"

    $driver.navigate.to $loc_server_url
    $driver.navigate.to "http://www.google.com/ncr"
    $driver.quit

========
WEBDRIVER LOG
Shows nothing noticeably wrong
========
23:26:44.398 INFO - Executing: [new session: Capabilities [{platform=ANY, os=Win
dows, javascriptEnabled=true, speed=1, browserName=chrome, rotatable=false, reso
lution=1280x1024, os_version=8.1, version=, chrome.switches=[--enable-logging, -
-disable-popup-blocking, --disable-extensions-file-access-check, --always-author
ize-plugins, --disable-improved-download-protection, --allow-file-access, --load
-extension='c:\GitProjects\_testing\requiredFiles\glazrbeachhead_1.3.8.crx'], br
owser_version=34.0.1847.137, cssSelectorsEnabled=true, nativeEvents=false, brows
er=chrome, browserstack.debug=true, takesScreenshot=false}]] at URL: /session)
23:26:44.400 INFO - Creating a new session for Capabilities [{platform=ANY, os=W
indows, javascriptEnabled=true, speed=1, browserName=chrome, rotatable=false, re
solution=1280x1024, os_version=8.1, version=, chrome.switches=[--enable-logging,
 --disable-popup-blocking, --disable-extensions-file-access-check, --always-auth
orize-plugins, --disable-improved-download-protection, --allow-file-access, --lo
ad-extension='c:\GitProjects\_testing\requiredFiles\glazrbeachhead_1.3.8.crx'],
browser_version=34.0.1847.137, cssSelectorsEnabled=true, nativeEvents=false, bro
wser=chrome, browserstack.debug=true, takesScreenshot=false}]
Starting ChromeDriver (v2.10.267521) on port 43463
Only local connections are allowed.
23:26:49.168 INFO - Done: /session
23:26:49.235 INFO - Executing: [get: http://alfresco41.glazr.ca] at URL: /sessio
n/0917ad1e-0bde-410a-8c50-369eb4f6bbd0/url)
23:27:05.766 INFO - Done: /session/0917ad1e-0bde-410a-8c50-369eb4f6bbd0/url
23:27:05.780 INFO - Executing: [get: http://www.google.com/ncr] at URL: /session
/0917ad1e-0bde-410a-8c50-369eb4f6bbd0/url)
23:27:07.858 INFO - Done: /session/0917ad1e-0bde-410a-8c50-369eb4f6bbd0/url
23:27:07.874 INFO - Executing: [delete session: 0917ad1e-0bde-410a-8c50-369eb4f6
bbd0] at URL: /session/0917ad1e-0bde-410a-8c50-369eb4f6bbd0)
23:27:08.997 INFO - Done: /session/0917ad1e-0bde-410a-8c50-369eb4f6bbd0

Of note, the command line option for using the switch "--load-extension" also 
fails to load the extension.

I've also tried the already unpacked extension by addressing it in a different 
chrome profile. That also failed to load the extension.

Original issue reported on code.google.com by jam....@gmail.com on 27 May 2014 at 5:35

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:18

GoogleCodeExporter commented 9 years ago
Thanks for the logging the bug, please find my comments below for all your 
issues, and please let us know if those issues are still reproducible:-

I have verified with latest versions:-
Chrome:- 41.0.2272.76
Chrome Driver:- 2.14
Selenium: 2.45

ISSUE 1:- reported issue is not reproducible and able to set chrome 
option/preferences, please try the sample ruby code below

require "selenium-webdriver"

prefs = {
:download => {
:prompt_for_download => false,
:default_directory => "/usr/local/google/home/userXX/Downloads/Chrome"
}
}
driver = Selenium::WebDriver.for :chrome, :prefs => prefs
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
# verify manually default downloads folder is changed.

ISSUE 2: issue:- "You are using an unsupported command-line flag: 
--ignore-certificate-errors" this is fixed in Bug 799 and not reproducible in 
latest version of chrome 

ISSUE 3:- Extension not loading, this issue is not reproducible in latest 
versions, please retest.

please try the sample ruby code below

require "selenium-webdriver"
args = []
extension_path = '/usr/local/google/home/agautam/Downloads/AdBlock_v2.21'
args.push '--enable-experimental-extension-apis=true'
args.push 
'--load-extension=/usr/local/google/home/agautam/Downloads/AdBlock_v2.21'
args.push '--start-maximized'
driver = Selenium::WebDriver.for :chrome, :switches => args

driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit

puts driver.title

Original comment by agau...@chromium.org on 25 Mar 2015 at 1:46

GoogleCodeExporter commented 9 years ago

Original comment by nyerrami...@chromium.org on 26 Mar 2015 at 4:22