Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
683ec101
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
683ec101
编写于
10月 17, 2017
作者:
E
Eileen M. Uchitelle
提交者:
GitHub
10月 17, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30876 from y-yagi/selenium_chrome_headless
Add headless chrome driver to System Tests
上级
262dc918
ada05850
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
41 addition
and
1 deletion
+41
-1
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+4
-0
actionpack/lib/action_dispatch/system_test_case.rb
actionpack/lib/action_dispatch/system_test_case.rb
+2
-0
actionpack/lib/action_dispatch/system_testing/driver.rb
actionpack/lib/action_dispatch/system_testing/driver.rb
+17
-1
actionpack/test/abstract_unit.rb
actionpack/test/abstract_unit.rb
+4
-0
actionpack/test/dispatch/system_testing/driver_test.rb
actionpack/test/dispatch/system_testing/driver_test.rb
+8
-0
actionpack/test/dispatch/system_testing/system_test_case_test.rb
...ack/test/dispatch/system_testing/system_test_case_test.rb
+6
-0
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
683ec101
*
Add headless chrome support to System Tests.
*Yuji Yaginuma*
*
Add ability to enable Early Hints for HTTP/2
If supported by the server, and enabled in Puma this allows H2 Early Hints to be used.
...
...
actionpack/lib/action_dispatch/system_test_case.rb
浏览文件 @
683ec101
...
...
@@ -121,6 +121,8 @@ def self.start_application # :nodoc:
#
# driven_by :selenium, using: :firefox
#
# driven_by :selenium, using: :headless_chrome
#
# driven_by :selenium, screen_size: [800, 800]
def
self
.
driven_by
(
driver
,
using: :chrome
,
screen_size:
[
1400
,
1400
],
options:
{})
self
.
driver
=
SystemTesting
::
Driver
.
new
(
driver
,
using:
using
,
screen_size:
screen_size
,
options:
options
)
...
...
actionpack/lib/action_dispatch/system_testing/driver.rb
浏览文件 @
683ec101
...
...
@@ -31,8 +31,24 @@ def register
end
end
def
browser_options
if
@browser
==
:headless_chrome
browser_options
=
Selenium
::
WebDriver
::
Chrome
::
Options
.
new
browser_options
.
args
<<
"--headless"
browser_options
.
args
<<
"--disable-gpu"
@options
.
merge
(
options:
browser_options
)
else
@options
end
end
def
browser
@browser
==
:headless_chrome
?
:chrome
:
@browser
end
def
register_selenium
(
app
)
Capybara
::
Selenium
::
Driver
.
new
(
app
,
{
browser:
@browser
}.
merge
(
@
options
)).
tap
do
|
driver
|
Capybara
::
Selenium
::
Driver
.
new
(
app
,
{
browser:
browser
}.
merge
(
browser_
options
)).
tap
do
|
driver
|
driver
.
browser
.
manage
.
window
.
size
=
Selenium
::
WebDriver
::
Dimension
.
new
(
*
@screen_size
)
end
end
...
...
actionpack/test/abstract_unit.rb
浏览文件 @
683ec101
...
...
@@ -449,3 +449,7 @@ class DrivenByRackTest < ActionDispatch::SystemTestCase
class
DrivenBySeleniumWithChrome
<
ActionDispatch
::
SystemTestCase
driven_by
:selenium
,
using: :chrome
end
class
DrivenBySeleniumWithHeadlessChrome
<
ActionDispatch
::
SystemTestCase
driven_by
:selenium
,
using: :headless_chrome
end
actionpack/test/dispatch/system_testing/driver_test.rb
浏览文件 @
683ec101
...
...
@@ -17,6 +17,14 @@ class DriverTest < ActiveSupport::TestCase
assert_equal
({
url:
"http://example.com/wd/hub"
}),
driver
.
instance_variable_get
(
:@options
)
end
test
"initializing the driver with a headless chrome"
do
driver
=
ActionDispatch
::
SystemTesting
::
Driver
.
new
(
:selenium
,
using: :headless_chrome
,
screen_size:
[
1400
,
1400
],
options:
{
url:
"http://example.com/wd/hub"
})
assert_equal
:selenium
,
driver
.
instance_variable_get
(
:@name
)
assert_equal
:headless_chrome
,
driver
.
instance_variable_get
(
:@browser
)
assert_equal
[
1400
,
1400
],
driver
.
instance_variable_get
(
:@screen_size
)
assert_equal
({
url:
"http://example.com/wd/hub"
}),
driver
.
instance_variable_get
(
:@options
)
end
test
"initializing the driver with a poltergeist"
do
driver
=
ActionDispatch
::
SystemTesting
::
Driver
.
new
(
:poltergeist
,
screen_size:
[
1400
,
1400
],
options:
{
js_errors:
false
})
assert_equal
:poltergeist
,
driver
.
instance_variable_get
(
:@name
)
...
...
actionpack/test/dispatch/system_testing/system_test_case_test.rb
浏览文件 @
683ec101
...
...
@@ -22,6 +22,12 @@ class SetDriverToSeleniumTest < DrivenBySeleniumWithChrome
end
end
class
SetDriverToSeleniumHeadlessChromeTest
<
DrivenBySeleniumWithHeadlessChrome
test
"uses selenium headless chrome"
do
assert_equal
:selenium
,
Capybara
.
current_driver
end
end
class
SetHostTest
<
DrivenByRackTest
test
"sets default host"
do
assert_equal
"http://127.0.0.1"
,
Capybara
.
app_host
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录