有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
chromium-browser --disable-web-security --user-data-dir=~/ChromeUserData/
其他回答
在Windows 10上,以下功能将起作用。
<<path>>\chrome.exe --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt
创建快捷方式:
粘贴命令:
cmd/c start chrome--禁用web安全--用户数据dir=“c:\temp\chrome”
以管理员身份运行
对于Selenium Webdriver,在这种情况下,您可以使用适当的参数(或“开关”)让Selenium启动Chrome。
@driver = Selenium::WebDriver.for(:Chrome, {
:detach => false,
:switches => ["--disable-web-security"]
})
是的。对于OSX,打开终端并运行:
$ open -a Google\ Chrome --args --disable-web-security --user-data-dir
--OSX上的Chrome 49+需要用户数据目录
对于Linux运行:
$ google-chrome --disable-web-security
此外,如果您试图访问本地文件以用于开发目的,如AJAX或JSON,也可以使用此标志。
--allow-file-access-from-files
对于Windows,进入命令提示符并进入Chrome.exe所在的文件夹,然后键入
chrome.exe --disable-web-security
这将禁用同源策略并允许您访问本地文件。
更新:对于Chrome 22+,您将看到一条错误消息,上面写着:
您正在使用不受支持的命令行标志:--disable web security。稳定和安全将受到影响。
然而,您可以在开发时忽略该信息。
这是一个不断移动的目标。。。。今天我需要添加另一个标志以使其生效:--禁用站点隔离试验
操作系统X:open/Applications/Google\Chrome.app--args--用户数据dir=“/var/tmp/Chrome_dev_2”--禁用web安全--禁用站点隔离测试