问题标签 [google-chrome-headless]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angularjs - 无头镀铬:镀铬无法到达
我正在使用无头 Chrome 来运行量角器测试。它运行了一段时间,但之后我收到以下错误。
[15:36:30] E/launcher - chrome 无法访问(会话信息:headless chrome=59.0.3071.115)(驱动程序信息:chromedriver=2.30.477690(c53f4ad87510ee97b5c3425a14c0e79780cdf262),平台=Mac OS X 10.11.6 x86_64)(警告:服务器没有提供任何堆栈跟踪信息)命令持续时间或超时:5毫秒构建信息:版本:'3.4.0',修订:'未知',时间:'未知'
配置如下图所示。
当我在没有“无头”参数的情况下运行时,测试运行良好。
python - Selenium Chrome Headless 下载文件
我使用无头 chrome 和 selenium,但我在下载文件时遇到问题。使用选项:
如果没有使用无头镀铬,则文件下载成功,但如果无头工作,则没有任何操作。我该如何解决?
selenium-webdriver - chromedriver headless alerts
I have this issue with selenium webdriver tests with chromedriver. Although I can run tests succesfully when using Chrome browser I can't run the same tests in headless mode.
I cannot handle the Js alerts. Actually when taking a screenshot it seems that the alert won't even pop-up.
I have tried several workarounds:
1) driver.window_handles
--> No other window seems to be present
2) driver.execute_script("window.confirm = function(){return true;}")
--> Nothing changed with that script
3) element = WebDriverWait(driver, 20).until(EC.alert_is_present())
and of course an explicit wait
In browser mode I use a plain:
Anyone else having this issue with alerts in headless mode?
- chromedriver v.2.30.477691
- Chrome Version 59.0.3071.115
python-3.x - 使用 Selenium (Python) 为 Chrome Headless 设置 Accepted-Lang
通过 ChromeOptions 设置 Accepted-Lang 标头适用于常规 Chrome
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
我正在尝试切换到新的无头 Chrome,但显然在检查 validator.w3.org 上的标头时此选项无效。我可以用另一种方式改变它们吗?有人知道是否会支持此功能吗?
在 MacOS 上使用 Chrome 60、Chromedriver 2.30、Selenium 3.4.3、Python 3.6.1
使用此代码:
谢谢!
angular - 无法运行无头镀铬量角器角 2 窗口
在所有关于 headless chrome 自动化测试的文档中,很少有关于在 windows 上做的。对于 Angular 2 中完全开发的应用程序,使用 headless chrome 进行自动化测试(尤其是 e2e)的信息更少。
我有一个相当大的 Angular 2 应用程序,我运行 170 次量角器测试,每次大约需要 30 分钟。我想使用 headless chrome 选项来获得更快的执行速度,当然,也不会一直弹出窗口。
至今 -
- 为量角器配置添加了选项
- 更新量角器,webdriver-manager(到 chromedriver_2.31)
- 启动并运行 chrome beta(60)
- Angular 4 开箱即用的应用程序(添加了类似的测试用例)完美运行
我的问题 - 我错过了什么?除了chrome驱动程序是最新的之外,没有提到任何地方的最低角度要求或任何软件包的最低版本。有没有人尝试在现有的 Angular 2 应用程序中使用它?如果成功了,请分享。
在第 2 步之后,我收到以下错误
jenkins - how to place and use headless chrome binary on jenkins (linux) instance
actually i am struggling with absence of bigger picture on how to proceed , here is the case :
I have protractor test suite running headless using Chrome 60 (beta) binary by giving binary location in chrome options in windows environment.
I want to port this to available CI CD Jenkins instance (linux) and run headless there. I can think of two approaches :
Approach 1 :
Install chrome plugin in jenkins , so chrome becomes available to be driven by chrome driver < webdriver modules .so that i can use jenkins job as shown below :
npm run start
(from script , runs webdriver-manager start )
npm run update
(from script , runs webdriver-manager update )
npm run test
(from script , runs protractor protactor.conf.js )
Approach 2 : install chrome as module like other npm modules .then
npm run start
(from script , runs webdriver-manager start )
npm run update
(from script , runs webdriver-manager update )
npm run test
(from script , runs protractor protactor.conf.js )
I have looked into simple-headless-chrome , headless-chromium , chrome-runner npm modules , but not able to understand how these will work .
My understanding is to somehow have chrome binaries in node_modules and give path for chrome binaries in chrome options so that chrome driver can find it .
Can anyone enlighten me a little bit about bigger picture and how things will workout for Second approach .As i want dont have access to get chrome plugin installed on jenkins server and want to keep my setup independent.(nodejs and npm , java etc are available in jenkins)
ruby - 带有 chrome 窗口的无头 chrome 运行测试
我正在使用 capybara、cucumber 和 poltergeist 进行自动化测试 web 应用程序我决定从 poltergeist (phantomjs) 切换到无头 chrome,在 env.rb 中注册了驱动程序:
然后我注册了其他驱动程序设置:
当您运行测试时,Chrome 已加载,但没有活动窗口。那么它应该工作吗?很快我打算在 docker 容器(没有 GUI 的 ubuntu)中运行测试,是否有必要安装 Chrome 浏览器?
Mac OS X 10.12.5 Chrome 60 Chromedriver 2.31
宝石:selenium-webdriver (3.4.4, 2.53.4, 2.53.0) capybara (2.14.4, 2.10.1, 2.6.2, 2.4.4) chromedriver-helper (1.0.0)
python - Headless Chrome 导航到页面,点击链接页面,然后 printToPDF
我必须打印从产品信息页面链接到的所有 HTML 页面: http ://prod.adv-bio.com/ProductDetail.aspx?ProdNo=1197
我已经设置了一个测试脚本,看看我是否可以只对其中一个 HTML 文件执行此操作。我使用了 PyChromeDevTools 和 Selenium,希望我可以使用 DevTools 中的 printToPDF 功能,同时使用 Selenium 来点击我需要点击的链接。
这是我到目前为止的代码:
我收到了这个错误
我已将 chromedriver 更新到 2.31 并拥有 chrome 版本 60,我应该使用 canary 吗?我很感激这方面的任何帮助。
google-chrome - 如何在 Windows 10 的 Chrome 60 中使用 Headless Chrome?
我一直在看以下关于无头 Chrome 的文章:
https ://developers.google.com/web/updates/2017/04/headless-chrome
我刚刚将 Windows 10 上的 Chrome 升级到版本 60,但是当我从命令行运行以下任一命令时,似乎什么都没有发生:
我正在从以下路径(Windows 上 Chrome 的默认安装路径)运行所有这些命令:
当我运行命令时,某些东西似乎会处理一秒钟,但我实际上什么也没看到。我究竟做错了什么?
谢谢。
编辑:
正如 Mark Rajcok 所指出的,如果您添加--enable-logging
到--dump-dom
命令中,它就会起作用。此外,该--print-to-pdf
命令在 Chrome 61.0.3163.79 中也可以正常工作,但您可能必须为输出文件指定不同的路径才能获得保存它的必要权限。
因此,以下两个命令对我有用:
我想下一步是能够通过带有 DOM 选择器之类的 PhantomJS 之类的转储 DOM,但我想这是一个单独的问题。
编辑#2:
值得一提的是,我最近遇到了一个用于 Headless Chrome 的 Node API,名为 Puppeteer ( https://github.com/GoogleChrome/puppeteer ),它非常易于使用并提供了 Headless Chrome 的所有功能。如果您正在寻找一种使用 Headless Chrome 的简单方法,我强烈推荐它。
google-chrome - 是否可以在带有扩展的无头模式下运行 Google Chrome?
我无法使用无头模式在 Google Chrome 中使用我当前安装的扩展程序。有什么方法可以启用它们吗?
检查扩展是否有效的一种简单方法是添加例如“ Comic Sans Everything ”扩展。
所以谷歌看起来像这样:
但是,如果我使用无头模式 ( google-chrome --headless --disable-gpu --screenshot https://www.google.com
) 截取页面,结果是: