Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.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
Python Selenium无头Chromedriver拍摄全白色屏幕截图和can';找不到任何元素?_Python_Selenium_Selenium Chromedriver_Google Chrome Headless - Fatal编程技术网

Python Selenium无头Chromedriver拍摄全白色屏幕截图和can';找不到任何元素?

Python Selenium无头Chromedriver拍摄全白色屏幕截图和can';找不到任何元素?,python,selenium,selenium-chromedriver,google-chrome-headless,Python,Selenium,Selenium Chromedriver,Google Chrome Headless,我正在设置一个脚本来刷新某个应用程序的缓存,当运行chromedriver时,并非所有xpath定位器都可以正常工作。我设置了chrome选项 chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') chrome_options.add_argument("window-size=1920,1080") driver = w

我正在设置一个脚本来刷新某个应用程序的缓存,当运行chromedriver时,并非所有xpath定位器都可以正常工作。我设置了chrome选项

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument("window-size=1920,1080")

driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

driver.get('link here')

driver.save_screenshot('file.png')

这里的link表示我将刷新缓存的特定链接

当运行headless时,我得到一个无法定位元素的错误,屏幕截图将作为空白页返回。当铬合金没有无头运行时,情况完全相反。我现在遇到了一个障碍,任何帮助或建议都将不胜感激


我已尝试设置窗口大小以及更改chromedriver的路径。

您可以在此处或DOM提供您的链接吗?@Rock link是一个公司内部安全网站,非常确定它不对打开的web开放,它未定位的元素是驱动程序。通过链接文本(“DefaultTFNProductList”)查找元素。单击()但我试着对它进行注释,它会找到提供的任何元素,而不是xpath、类名、id。请检查元素是否在iFrame中?尝试最大化浏览器来定位元素。您使用的是哪个版本的chrome和ChromeDriver?