Selenium Prevent chromedriver New Window from getting Focus on Ubuntu 16.04 LTS

Question:

I have a selenium script that scraps a website. Each time selenium driver opens a new link, the Chrome driver launches a new instance of Google Chrome and provides input to a search query using send_keys.
And, the newly opened chrome tab appears in front of any other windows (i.e Nautilus or say Firefox) open on my Ubuntu 16.04 LTS

I tried running the script in different workspace but still it automatically switches workspace to show the newly opened chrome tab (by the script).
Also, Even if I make the currently visible window Always on top by right clicking on the Title bar. It still loses focus as soon as the chrome browser opens the link (On the other workspaces)

Is there any way to prevent chrome driver’s newly opened tab from getting focus?

Asked By: Wasi

||

Answers:

I couldn’t find a solution for chromedriver so, I just switched back to phantomjs again.

Download link of PhantomJS: http://phantomjs.org/download.html

Answered By: Wasi

Start a headless browser can be an option

final var options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
options.addArguments("--headless");

final var driver = new ChromeDriver(options);
Answered By: deFreitas