Skip to content

Commit d3e95e2

Browse files
committed
rb - update logging implementation to support chrome and safari by default
1 parent fc8db8e commit d3e95e2

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,11 @@ def getLog(type)
534534
data = execute :getLog, {}, :type => type.to_s
535535

536536
Array(data).map do |l|
537-
LogEntry.new l.fetch('level'), l.fetch('timestamp'), l.fetch('message')
537+
begin
538+
LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
539+
rescue KeyError
540+
next
541+
end
538542
end
539543
end
540544

rb/lib/selenium/webdriver/remote/capabilities.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ def chrome(opts = {})
7474
new({
7575
:browser_name => "chrome",
7676
:javascript_enabled => true,
77-
:css_selectors_enabled => true
78-
}.merge(opts))
77+
:css_selectors_enabled => true,
78+
:loggingPrefs => {:browser => "ALL",
79+
:driver => "ALL"}
80+
}.merge(opts))
7981
end
8082

8183
def edge(opts = {})

rb/spec/integration/selenium/webdriver/options_spec.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,37 @@ module WebDriver
2424
describe Options do
2525

2626
# Not supported in W3C Spec
27-
not_compliant_on :driver => :marionette do
27+
not_compliant_on :browser => :marionette do
2828
describe 'logs' do
29-
compliant_on :driver => [:firefox] do
29+
compliant_on :driver => :remote do
30+
# Phantomjs Returns har instead of driver
31+
not_compliant_on :browser => :phantomjs do
32+
it 'can fetch available log types' do
33+
expect(driver.manage.logs.available_types).to include(:browser, :driver, :server, :client)
34+
end
35+
end
36+
end
37+
38+
# Phantomjs Returns har instead of driver
39+
not_compliant_on :browser => :phantomjs do
3040
it 'can fetch available log types' do
31-
expect(driver.manage.logs.available_types).to eq([:browser, :driver])
41+
expect(driver.manage.logs.available_types).to include(:browser, :driver)
3242
end
43+
end
3344

45+
# All other browsers show empty
46+
compliant_on :browser => :firefox do
3447
it 'can get the browser log' do
3548
driver.navigate.to url_for("simpleTest.html")
3649

3750
entries = driver.manage.logs.get(:browser)
3851
expect(entries).not_to be_empty
3952
expect(entries.first).to be_kind_of(LogEntry)
4053
end
54+
end
4155

56+
# Phantomjs Returns har instead of driver
57+
not_compliant_on :browser => :phantomjs do
4258
it 'can get the driver log' do
4359
driver.navigate.to url_for("simpleTest.html")
4460

0 commit comments

Comments
 (0)