English 中文(简体)
• 如何绕过? (ium/贾瓦)
原标题:ChromeDriver Version 121+ Forces "Save As" Dialog - How to Bypass? (Selenium/Java)

一直在使用位于 Java的 Chrome骑手的Selenium网络司机进行自动存档下载。

我的守则是完美无缺的,直到我更新了“ Chrome”版121+,该代码为“ Chrome119”,问题似乎始于“ Chrome条码>121.0.6167.140。 现在,浏览器似乎迫使“Save As”方言箱露面,即使我为避开 preferences。

而且,我只想以不知的方式执行测试案例。

这也没有发挥作用。

options.addArguments("disable-features=DownloadBubble,DownloadBubbleV2");
问题回答

下载波段能力需要增加的论点是:< 编码> 。

此外,分享我用于使 Chrome能够下载档案的能力(在 Java):

Map<String, Object> prefs = new HashMap<>();

prefs.put("download.default_directory", System.getProperty("user.dir"));
prefs.put("safebrowsing.enabled", true);

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments(
    "--no-sandbox",
    "--remote-allow-origins=*",
    "--disable-features=DownloadBubble,DownloadBubbleV2",
    "--disable-popup-blocking"
);

我试图无动于衷,允许我下载档案。

options.addArguments("--headless");

页: 1 这在我一边奏效。

import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.HttpClientBuilder
import com.fasterxml.jackson.databind.ObjectMapper

ChromeOptions options = new ChromeOptions();
options.addArguments(args); // Use your args
options.setExperimentalOption("prefs", prefs); // Use your prefs

ChromeDriverService driverService = ChromeDriverService.createDefaultService();
ChromeDriver driver = new ChromeDriver(driverService, options);

Map<String, Object> commandParams = new HashMap<>();
commandParams.put("cmd", "Page.setDownloadBehavior");
Map<String, String> params = new HashMap<>();
params.put("behavior", "allow");
params.put("downloadPath", "//yourDownloadPath");
commandParams.put("params", params);
ObjectMapper objectMapper = new ObjectMapper();
HttpClient httpClient = HttpClientBuilder.create().build();
String command = objectMapper.writeValueAsString(commandParams);
String u = driverService.getUrl().toString() + "/session/" + driver.getSessionId() + "/chromium/send_command";
HttpPost request = new HttpPost(u);
request.addHeader("content-type", "application/json");
request.setEntity(new StringEntity(command));
httpClient.execute(request);




相关问题
Redirect to cache URL in Chrome browser

self.location = cache: + self.location I want to redirect from "[URL]" to "cache:[URL]". I just want this code to work in Chrome browser.

我如何更新/重载 Chrome延?

I m在4号 Chrome(目前为4.0.249.0)中开发一个延伸点,显示用户在地位酒吧中的形象。 Ive设计了一个供用户使用的备选办法网页......

Setting Opacity in CSS For Chrome

I ve tried the following: (this is actually for fancybox, as the overlay does not show in chrome/safari: $("#fancy_overlay").css({<br /> background-color : opts....

Chrome Blocking Javascript, Google Wave, Google Gadgets

Project: Developing a gadget template for Google Wave which will allow my Flash movies to interact with the Wave api. I had to adapt the existing Flex application so that it would work with ...

image height using jquery in chrome problem

$( img ).height() returns 0 in chrome, but it returns the actual height in IE and firefox. Whats the actual method to get the height of the image in chrome?

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Table cells bad rendering with Google Chrome/Webkit

On the following code, COL1A and COL3A are not 50% height with Chrome or Webkit. It works fine with IE7 and Firefox. <table border="1"> <tr> <td height="100%">COL 1A</td>...

热门标签