Can not start Chrome in Headless Mode - java

I am trying to use the Chrome Headless mode on Selenium Webdriver to test a script
with different arguments I get
NoSuchElementException - when finding by xpath
chrome not reachable - webdriverexception
chrome failed to start -
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless","--disable-gpu");
webDriver = new ChromeDriver(options);
this is the initialization.
No problem with the xpath as it is working on Normal mode.
Chrome version 60
Selenium 3.5.0
Chrome driver 2.32

Related

which chromedriver version supports electron app?

I try to run electron app using the following code:
#Test
public void testElectron() {
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(this.electronPath);
WebDriver driver = new ChromeDriver(chromeOptions);
}
But I get the following error:
Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280#{#1761}) on port 37592
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
org.openqa.selenium.SessionNotCreatedException: session not created: This
version of ChromeDriver only supports Chrome version 87
Current browser version is 80.0.3987.165 with binary path src\main\resources\electron\electronApp.exe
Is there a specific chromedriver the is suitable for electron app (for selenium java)?
This error message...
Current browser version is 80.0.3987.165 with binary path src\main\resources\electron\electronApp.exe
...implies that the Chrome browser version is 80.0.
Solution
So as a solution you have to download the matching ChromeDriver
from ChromeDriver v80.0.3987.106 repository.

How to disable/remove the chrome headless disclaimer in selenium and java

I have automated a page and running through 'Chromeheadless', Script is in an infinite loop because there is a chrome automation disclaimer and under that, the actual element to click exists.
The automation page is attached below:
The Automation code to make chrome as headless is as below:
String chromePath = getChromeDriverPath();
System.setProperty("webdriver.chrome.driver", chromePath);
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu", "--window-size=1920,1200","--ignore-certificate-errors");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
If I run the script using a normal chrome driver, it is working fine. The issue with only chrome headless mode. Please help me how to disable/remove the disclaimer to proceed with the execution.

unable to run the HtmlUnit Driver with selenium Webdriver using java

This is the code :
And error :
I am trying to run the script in headless browser but it gives the error as mentioned in screenshot.
I will suggest to use phantomjs instead of HTMLUnit driver for headless automation
Now if you want to use headless with phantomjs. download the stable build of phantomjs for your headleass jobs. download it from below link :-
http://phantomjs.org/download.html
Now add System.setPropertybefore driver instance
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // not really needed: JS enabled by default
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:/phantomjs.exe");
WebDriver driver = new PhantomJSDriver(caps);
refer the link below for more info :-
http://seleniumworks.blogspot.in/2013/03/headless-browser-testing-using.html

Could not able to run selenium scripts on Firefox 50.1.0 with selenium 3.3.1

Recently I have migrated my automation scripts from selenium 2.53 to 3.3.1 version, and we could not able to run scripts in Firefox version due to below exception. i m using Firefox 50.1.0 and gecko v0.15.0
Exception in: TS_Testorg.openqa.selenium.SessionNotCreatedException: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
You would need to provide firefox binary location. One way of doing it is by the below code -
FirefoxOptions ffOptions = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //Location where Firefox is installed
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("moz:firefoxOptions", options);
FirefoxDriver driver = new FirefoxDriver(capabilities);
driver.get("http://www.google.com");
More info here - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

Selenium Webdriver - Opera - Unable to receive message from renderer

I'm trying to run my Java selenium tests using Opera (version 31). I'm using last version of Selenium Webdriver (2.47.1) and last version of OperaChromiumDriver (0.2.2).
I've tried to use next method to instantiate Opera:
System.setProperty("webdriver.chrome.driver", "\\path\\to\\my\\operadriver.exe");
WebDriver driver = new ChromeDriver();
And i've tried another method with RemoteWebdriver:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);
(these methods are described in answers to this question: How to use OperaChromiumDriver for opera version >12.X)
Both methods have the same problem.
Opera opens, but then crushes with next exception:
org.openqa.selenium.SessionNotCreatedException: session not created exception from disconnected: Unable to receive message from renderer
(Session info: Opera with embedded Chromium 0.1889.230)
(Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 x86_64
(WARNING: The server did not provide any stacktrace information)
Firefox, Chrome and IE drivers work as it should be, i have such problem only with OperaChromiumDriver.
Can anyone help me with this issue?
Try to instantiate OperaDriver like this instead:
File operaFile = new File("\\path\\to\\my\\operadriver.exe");
System.setProperty("webdriver.opera.driver", operaFile.getAbsolutePath());
WebDriver driver = new OperaDriver();
In my application, .getAbsolutePath() works but just specifying the path in .setProperty does not. No idea why, since the string output of either is identical.
Unfortunately I am still unable to use OperaDriver in my tests because it becomes unresponsive after loading a few pages. This occurs on 3 different machines running different versions of Windows and returns only this error:
[SEVERE]: Timed out receiving message from renderer:
FirefoxDriver, ChromeDriver, and InternetExplorerDriver all work fine with my tests, so, whatever.

Categories

Resources