最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

selenium webdriver - Chromedriver does not load web page in headless mode - Stack Overflow

programmeradmin4浏览0评论

Our team is experiencing an issue with Selenium in Ruby that web page does not load when using Chrome browser in headless mode, page loads properly when running test with head. Also, we noticed that when we take a screenshot of page while in headless mode, it loads a little bit. We implemented a very silly hack to load page in headless mode, but it would be good to hear from community if this issue known and/or how people solve it. Thank you!

OS: Mac OS Sequoia
Tool: Selenium (Capybara) with Ruby 3.2.0
Chromedriver: "ChromeDriver 134.0.6998.90 (219ee74681fc640b1ee1af1c99df3729a0ec25a8-refs/branch-heads/6998@{#1900})"

Our "hack" to load page in headless mode:

  def chrome_headless_screenshot_hack
    if browser.include?('chrome_headless')
      10.times do
        page.save_screenshot("chrome_headless_hack.png")
        sleep 1
      end
    end
  end
发布评论

评论列表(0)

  1. 暂无评论