简体   繁体   中英

Starting Selenium Standalone headless with RSelenium

I am new to selenium, but I managed to install and run the standalone version on my computer. It is working very good, but I would like to try headless testing.

I am starting the standalone with

java -jar selenium.jar

Is there a command/option to start chrome headless?

EDIT: I found my mistake and the solution. The above command is used to start the server locally, it has nothing to do with the headless part. Headless or not is actually set up in the R Script:

Headless:

library(wdman)
library(RSelenium)
cDrv <- chrome()
eCaps <- list(chromeOptions = list(
  args = c('--headless', '--disable-gpu', '--window-size=1280,800')
))
remDr<- remoteDriver(browserName = "chrome", port = 4444, 
                     extraCapabilities = eCaps)

With Chrome open:

library(RSelenium)
    remDr <- remoteDriver(
      remoteServerAddr = "localhost",
      port = 4444,
      browserName = "chrome"
    )

You need to use that:

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
WebDriver driver = new ChromeDriver(options);

For more information you can consult here .

I hope it helped you!

you can add below line in option:

chrome_options.add_argument("--headless")

Selenium.jar starts a selenium server. This server can talk to webdrivers and the drivers then talk to the browser to do things:

Now if you are using just webdriver API and running your scripts on the same mechine the browser is present then you don't need selenium server. webdrivers like firefox and chromium exposes themselves with API so you don't need selenium server.

This have nothing to do with "headless", headless is configured in your script as capability or argument. THis information is send to seleniumserver > then to driver> then to browser

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM