java - 如何使用Java禁用selenium Webdriver上的所有断点?

标签 java selenium selenium-webdriver

我想使用 Java 禁用 selenium Webdriver 上的所有断点(来自 debugger; javascript 目标应用程序)。我的目标应用程序每 x 秒运行一个断点并停止我的 selenium 运行

enter image description here

ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");

options.addArguments("--disable-  ???? ");     <= ???????

WebDriver driver = new ChromeDriver(options);
driver.get("http://rd.huangpuqu.sh.cn/website/html/shprd/shprd_tpxw/List/list_0.htm");

你可以找到所有chome选项here但我没有找到这个功能。

编辑:

我尝试了这个(通过 Javascript 通过 JavascriptExecutor)但不起作用:

((JavascriptExecutor) driver).executeScript("debugger; = function(){};");

((JavascriptExecutor) driver).executeScript("debugger = function(){};");

((JavascriptExecutor) driver).executeScript("window.debugger = function(){};");

编辑2:

我尝试通过 javascript 解决此问题,但不起作用:

计算器:How to disable debugger; command in JS?

调试器不是 JavaScript 成员,它不能被覆盖。

编辑3:

与此同时,我在 selenium 库上提出了一个新问题 here

最佳答案

调用脚本来重新定义调试器似乎是个好主意,但我认为你可以尝试这个:

((JavascriptExecutor) driver).executeScript("debugger = function(){};");

或者:

((JavascriptExecutor) driver).executeScript("window.debugger = function(){};");

关于java - 如何使用Java禁用selenium Webdriver上的所有断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56733792/

相关文章:

java - 用于订单顶部或第一条记录的 Spring java MongoDB @Query 注释

java - 将 Spring Roo 与 JSF 2.0 + Primefaces 结合使用时出现的问题

java - JDBC "database table is locked"错误

java - 如何通过 window.open 将值从一个 jsp 传递到另一个

java - 如何使用 appium 坐标滚动

java - 在selenium中使用safari驱动程序的图像位置

python - 如何在 Jupyter 中通过 Selenium 和 Python 单击文本为 Find What County I'm In 的按钮

python - 错误 : GDK_BACKEND does not match available displays; Running Selenium using Crontab

c# - Selenium C# 表 - 读取每个值并添加它们并以 List<string> 形式返回

node.js - 来自 Selenium : UnhandledPromiseRejectionWarning: Error: ECONNREFUSED connect ECONNREFUSED 的错误