Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Chrome无头浏览器不适用于特定网站_Java_Selenium_Google Chrome Headless_Headless Browser - Fatal编程技术网

Java Chrome无头浏览器不适用于特定网站

Java Chrome无头浏览器不适用于特定网站,java,selenium,google-chrome-headless,headless-browser,Java,Selenium,Google Chrome Headless,Headless Browser,我正在尝试为我的应用程序实现selenium+Java+Chrome Headless,但遇到异常“element not Interactiable”。我尝试过不同的窗口大小选择,但没有运气。 当我在chrome浏览器中以交互模式运行相同的代码时,它工作正常。 此外,我还尝试在另一个网站上运行相同的无头选项,效果良好 这里有我遗漏的东西吗。下面是ChromeOptions的代码和错误描述 ChromeOptions options = new ChromeOptions();

我正在尝试为我的应用程序实现selenium+Java+Chrome Headless,但遇到异常“element not Interactiable”。我尝试过不同的窗口大小选择,但没有运气。 当我在chrome浏览器中以交互模式运行相同的代码时,它工作正常。 此外,我还尝试在另一个网站上运行相同的无头选项,效果良好

这里有我遗漏的东西吗。下面是ChromeOptions的代码和错误描述

ChromeOptions options = new ChromeOptions();
        options.addArguments("--window-size=1920,1080");
        //options.addArguments("--window-size=1240,800");
        options.addArguments("--disable-gpu");
        options.addArguments("--disable-extensions");
        options.addArguments("--start-maximized");
        options.addArguments("--headless");
        driver = new ChromeDriver(options);
日志-

org.openqa.selenium.ElementNotInteractableException: element not interactable
  (Session info: headless chrome=85.0.4183.121)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'OM', ip: '172.XX.XX.XX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.121, chrome: {chromedriverVersion: 85.0.4183.87 (cd6713ebf92fa..., userDataDir: C:\Users\\AppData\Lo...}, goog:chromeOptions: {debuggerAddress: localhost:55464}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 
您正在设置
--window size=19201080
,但它被
--start maximized
标志覆盖


尝试删除此行
options.addArguments(“--start maximized”)
并运行代码。

我已尝试删除行“start maximized”。仍然面临相同的元素不可交互的问题。如果您使用驱动程序实例最大化窗口,是否可以签入代码。像这样的<代码>驱动程序.manage().window().maximize()是的,我已经验证了没有最大化窗口代码,仍然没有为特定的网站,这是我的项目只工作。在其他网站上,它工作正常,不会因为元素不可交互而出错。注意定位器XPath是正确的,因为它在可交互模式下工作正常。好的,酷。我在无头模式下也遇到了一些问题,但上面的解决方案对我很有效。在你的情况下,可能是其他原因。最后一个建议。你能试试不同的窗户尺寸吗。