Google Chrome - 如何以编程方式启用Chrome://将某些模块从禁用模式标记为启用模式? [英] Google Chrome - how can i programmatically enable chrome://flags some of the modules from disable mode to enabled mode?

查看:111
本文介绍了Google Chrome - 如何以编程方式启用Chrome://将某些模块从禁用模式标记为启用模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何自动化设置chrome标志以启用少量模块?



我设计了一个应用程序,它需要打开chrome://标志启用几个模块,否则整个应用程序不起作用,对于普通用户而言,它的噩梦就是做这么小的修改。

是否有任何JavaScript或Google应用程序引擎或其他方法可以从服务器端使用脚本或一些插件,我可以说点击这个,它会自动启用chrome中的模块:// flags?

解决方案

几乎每个Chrome标志都可以通过命令行进行设置。这里是命令行参数的详尽列表,但也保留在请注意,在新版本中会有更多!



编辑:这是全面,最新的Chrome命令行开关列表



所以基本上你会启动铬这些命令行标志已经设置。这是最好的方式。



你不能用Javascript或其他行为手动设置它。您可以通过程序设置(命令行标志除外)的唯一方式是使用 Capybara (一种工具它可以打开和控制浏览器,通常用于运行自动化测试),打开Chrome,然后手动导航到chrome:// flags,然后单击必要的组合框。

>编辑:Watir也和水豚一样好

Watir 是另一种浏览器自动化框架(类似于Capybara),但是更容易设置和开始。 下面是一些例子,介绍如何打开一个网页并选择一个组合框,这里有关于< href =http://watirwebdriver.com/chrome/ =nofollow noreferrer>在Chrome中使用它。您可以编写一个如下所示的单个ruby文件:

  require'watir-webdriver'
browser = Watir :: Browser.new:chrome
browser.gotochrome:// flags
browser.select_list(:id =>< combo box id>)select(Enabled)
...



使用WebDriver时坚持标志



Chrome拥有 - user-data-dir 开关,这是保存所有配置文件设置的地方。 Chrome使用的默认目录(在Windows / Mac / Linux上)[是记录在这里。通常,WebDriver以临时 - user-data-dir 启动,稍后在使用后删除临时文件夹。所以当你再次运行Chrome时,你设置的任何标志都会丢失!因此,将 - user-data-dir 设置为您用户的默认配置文件目录,然后您设置的任何标记都将保留。



编辑2 :添加了铬命令行标志的完整列表

编辑3 :添加了坚持在Webdriver的标志


How can I automate the setting of chrome flags to enable few modules?

I have application designed which requires on open the chrome://flags few modules enabled, otherwise the whole application does not work, for normal user its nightmare to do such small changes.

Is there any javascript or google app engine or other method to use from server side scripting or some plugin where i can say click this and it will automatically enable the modules inside chrome://flags?

解决方案

Almost every Chrome flag can be set via the command line. Here is a quite exhaustive list of command line parameters, but also keep in mind that there would be even more in newer versions!

EDIT: Here is the Comprehensive, up-to-date list of Chrome command line switches

So basically you would launch chrome with these command line flags already set. That's the best way to go about it.

You cannot manually set this using Javascript or other behavior. The only way you can set this programmatically (other than command line flags) is to use Capybara (a tool that can open and control browsers, generally used for running automated tests), open Chrome and then manually navigate to "chrome://flags" and click the necessary combo boxes.

EDIT: Watir is also as good as Capybara

Watir is another browser automation framework (similar to Capybara) but is much easier to setup and start with. Here are examples on how you would open a web page and select a combo box, and here are instructions on using it with Chrome. You can write a single ruby file which looks like:

require 'watir-webdriver'
browser = Watir::Browser.new :chrome
browser.goto "chrome://flags"
browser.select_list(:id => <combo box id>).select("Enabled")
...

Persisting the Flags when using WebDriver

Chrome has the --user-data-dir switch which is where all the profile settings are saved. The default directories that Chrome uses (on Windows/Mac/Linux) [is documented here. Generally, WebDriver launches with a temporary --user-data-dir, and later deletes the temporary folder after use. So whatever flags you set will be lost when you run Chrome again! So set --user-data-dir to your user's default profile directory, and then whatever flags you set will be persisted.

Edit 2: Added comprehensive list of chrome command line flags

Edit 3: Added instructions for persisting the flags in Webdriver

这篇关于Google Chrome - 如何以编程方式启用Chrome://将某些模块从禁用模式标记为启用模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆