google-chrome-headless

How to use headless chrome with capybara and selenium

牧云@^-^@ 提交于 2019-12-05 03:31:05
Chrome version: 59.0.3071.104 Using Cucumber, Capybara, Selenium to implement automation testing with Headless Chrome. features/support/env.rb require 'rubygems' require 'capybara/cucumber' Capybara.register_driver :selenium_chrome do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome, args: ['headless']) end Capybara.default_driver = :selenium_chrome When running a cucumber test, it says: WARN Selenium [DEPRECATION] :args or :switches is deprecated. Use Selenium::WebDriver::Chrome::Options#add_argument instead. What is the correct way to use capybara and selenium with Headless

Puppeteer wait until page is completely loaded

半腔热情 提交于 2019-12-05 01:40:35
问题 I am working on creating PDF from web page. The application on which I am working is single page application. I tried many options and suggestion on https://github.com/GoogleChrome/puppeteer/issues/1412 But it is not working const browser = await puppeteer.launch({ executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', ignoreHTTPSErrors: true, headless: true, devtools: false, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); const page = await browser.newPage

How to get console.log output in Terminal via Headless Chrome Runtime.evaluate

吃可爱长大的小学妹 提交于 2019-12-04 22:37:34
问题 I am following this issue post here: https://github.com/cyrus-and/chrome-remote-interface/issues/105 But I cannot seem to get console.log output in the Mac Terminal. It's probably inside the Chrome Devtools window which I don't see. So how do I get console.log output in Mac Terminal via Runtime.evaluate expression? My code below: const chromeLauncher = require('chrome-launcher'); const CDP = require('chrome-remote-interface'); const file = require('fs'); (async function() { async function

How to set window size in Selenium Chrome Python

青春壹個敷衍的年華 提交于 2019-12-04 18:37:27
The following code to resize a selenium chrome window does not work: driver.set_window_size(1920, 1080) time.sleep(5) size = driver.get_window_size() print("Window size: width = {}px, height = {}px.".format(size["width"], size["height"])) From which the output is: Window size: width = 1044px, height = 788px I've also tried using options to set the window size on driver creation (and lots of other things, seem comments below), but can't get it to work either: options.add_argument("--window-size=1920,1080") I am using selenium 3.14.0, chrome driver version 72.0.3626.109 and running in background

Chrome 73 stop supporting headless mode in background scheduled task?

孤街醉人 提交于 2019-12-04 14:18:41
We have a .NET program to run headless Chrome to snapshot web page to image, and here is the sample code: class Program { static void Main(string[] args) { var p = Process.Start( @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", $@"--headless --screenshot=E:\test{DateTime.Now:HHmmss}.png --disable-gpu --window-size=320,568 http://www.microsoft.com"); p.WaitForExit(); } } The console application is scheduled in Windows Task Scheduler with "Run whether user is logged on or not" option. The program works fine for months but failed yesterday, we noticed the Chrome version is 73 now.

How to access a site via a headless driver without being denied permission

醉酒当歌 提交于 2019-12-04 12:54:45
I am trying to retrieve the html code of a site using a headless chrome driver. However I get a "permission denied" message. If I use a "regular" driver it all works fine. Is there any way to bypass that? It's my first post so I do apologize for any potential mistakes in formatting from selenium import webdriver #Headless driver chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') driver1 = webdriver.Chrome(executable_path='./chromedriver', options=chrome_options, service_args=['--verbose', '--log-path=/tmp

ElementNotVisibleException when use headless Chrome browser

为君一笑 提交于 2019-12-04 02:01:56
When I run test script in headless mode chrome browser, element link is not visible, is not able to do linkElement.click() . in head mode is everything OK. All other info are in stacktrace. Anyone knows what to do, please? StackTrace: ERROR occurred: Message: element not visible (Session info: headless chrome=60.0.3112.90) (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 x86_64) Traceback (most recent call last): File "C:\nik-x.py", line 148, in main func(nik) File "C:\lib\support.py", line 121, in wrapper raise ret File "C:\lib

NoSuchElementException with headless chrome and selenium

好久不见. 提交于 2019-12-03 17:23:30
I am trying to use headless chrome for our selenium tests and have made the below changes: DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); options.addArguments("--disable-gpu"); options.addArguments("window-size=1800x1080"); desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options); My test logs into an internal page and then waits for the element to be visible: selenium.waitForElementVisible("xpath=//tr/td/div[@class[contains(., 'x-grid-cell-inner')] and text()='Global Test

How to get console.log output in Terminal via Headless Chrome Runtime.evaluate

别说谁变了你拦得住时间么 提交于 2019-12-03 14:13:42
I am following this issue post here: https://github.com/cyrus-and/chrome-remote-interface/issues/105 But I cannot seem to get console.log output in the Mac Terminal. It's probably inside the Chrome Devtools window which I don't see. So how do I get console.log output in Mac Terminal via Runtime.evaluate expression? My code below: const chromeLauncher = require('chrome-launcher'); const CDP = require('chrome-remote-interface'); const file = require('fs'); (async function() { async function launchChrome() { return await chromeLauncher.launch({ chromeFlags: [ '--headless', '--disable-gpu' ] }); }

Puppeteer: How to submit a form?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 04:52:21
Using puppeteer , how could you programmatically submit a form? So far I've been able to do this using page.click('.input[type="submit"]') if the form actually includes a submit input. But for forms that don't include a submit input, focusing on the form text input element and using page.press('Enter') doesn't seem to actually cause the form to submit: const puppeteer = require('puppeteer'); (async() => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://stackoverflow.com/', {waitUntil: 'load'}); console.log(page.url()); // Type our query