【问题标题】:Getting chrome.exe popup opened while executing selenium scripts在执行 selenium 脚本时打开 chrome.exe 弹出窗口
【发布时间】:2023-04-11 07:12:02
【问题描述】:

在 chrome 浏览器中执行 selenium webdriver 脚本时,我从位置 C:\Program Files\Google\Chrome\application\chrome.exe 打开了一个弹出窗口。

由于会话超时,此错误正在抛出。

注意:相同的代码库在其他机器上运行良好。

你能帮我解决这个问题吗?

我使用的代码如下:-

var arr = new string[7] {
    "--start-maximized", "--ignore-certificate-errors", "--disable-popup-blocking", "--disable-default-apps", "--auto-launch-at-startup", "--always-authorize-plugins", "--user-agent= " + FrameGlobals.userAgentValue
};
chromeCapabilities.AddArguments(arr);

WebDriverObj = new ChromeDriver(chromeCapabilities);

这就是我启动 chrome 浏览器的方式。没有提到代码库中的任何版本。

enter image description here

提前致谢。 盒马

【问题讨论】:

  • 检查您在 Webdriver 中使用的 Chrome 版本,以及实际安装的版本。我也遇到过类似的问题,而且很有帮助。
  • 感谢德米特里的回复! var arr = new string[7] {“--start-maximized”、“--ignore-certificate-errors”、“--disable-popup-blocking”、“--disable-default-apps”、“--启动时自动启动”、“--always-authorize-plugins”、“--user-agent=”+ FrameGlobals.userAgentValue }; chromeCapabilities.AddArguments(arr); WebDriverObj = new ChromeDriver(chromeCapabilities);这就是我启动 chrome 浏览器的方式。没有提到代码库中的任何版本。你能说一下它在哪里吗?

标签: google-chrome selenium-webdriver


【解决方案1】:

您可以将所有参数一一添加,然后将其传递给 Chromedriver,如下所示:-

        WebDriver driver=null;
        System.setProperty("webdriver.chrome.driver","./src//lib//chromedriver");
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("test-type");
        options.addArgument("--start-maximized");
        options.addArguments("--disable-web-security");
        options.addArguments("--allow-running-insecure-content");
        capabilities.setCapability("chrome.binary","./src//lib//chromedriver");
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        driver = new ChromeDriver(capabilities);
        driver.get("https://www.google.com/");

用上述论点替换你的论点

希望对你有帮助:)

【讨论】:

  • 我按照您的说法尝试过,但它仍在打开 exe 弹出窗口,并且浏览器没有执行任何操作。已附上截图供帖子中参考。
  • 我在启动我的网站时有In order to provide you with better service, we use cookies on our pages. By using this site, you agree to our Cookies Policy. 滑动弹出窗口,但在使用 chromedriver 启动时无法禁用它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-01
  • 1970-01-01
  • 2010-11-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多