I'm trying to launch my electron executable using selenium and java in a windows environment but I get a timeout error.
The code that I'm using is something like this:
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\myUser\\MyApp\\MyApp.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
WebDriver driver = new ChromeDriver(capabilities);
When previous code is executed, my application is launched but I can't continue with my test because I get this error from selenium:
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.33.506120,platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.21 seconds
......
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
I have tried with different versions of chromedriver and selenium but It doesn't work. Does anyone know what could be the problem?
Note: The error is thrown when this line is executed within HttpCommandExecutor class:
ProtocolHandshake.Result result = handshake.createSession(client, command);
You need to define chromeDriver args for your application path. I'm sharing my code with you. Hope to help.
ChromeOptions options = new ChromeOptions();
options.setBinary(binaryPath);
options.addArguments("--app=" + argPath);
options.setCapability("chromeOptions", options);
driver = new ChromeDriver(options);
Related
Selenium: 3.141.59;
Chromium Edge: Version 87.0.664.41 (Official build) (64-bit);
hub runs on linux, nodes on Windows 10.
I Would like to set up the RemoteWebDriver with Chromium Edge version 87. I have tried various options, and I am currently most successful with:
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(options);
RemoteWebDriver drv = new RemoteWebDriver(new URL(globalSetting.getHubUrl()),
edgeOptions);
drv.get("http://www.google.com");
With this the edge browser starts, but is unable to connect to the google url, because it is stuck in RemoteDriver setup. After some time, I get the a timeout and the message: WebDriverException: unknown error: unrecognized Chrome version: Edg/87.0.664.41
[With Chrome (google) it works fine.]
I red somewhere that this merge is not working with newer Chromium Edge and EdgeOptions should be used instead. But I only found Python code and it uses a field which EdgeOption in Java does not have (options.useChromium = true).
Has anybody been successful with Chromium Edge 86/87 and RemoteWebDriver in Java? If so could you provide a code example?
Google Chrome 75.0.3770.80 is installed on Docker image on CentOS 7
Chrome driver 75.0.3770.80 is checked-in with the framework
And docker container shows the correct version for both chrome browser and chrome driver, means both are installed successfully.
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + File.separator+"path/chromedriver");
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--headless");
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.merge(chromeCapabilities);
driver = new ChromeDriver(options);
Xvfb is set on Container and shows below output:
DISPLAY=:99
root 33 13 0 05:42 ? 00:00:00 Xvfb :99 -screen 0 1920x1920x24
When i try to launch the Chrome browser, it shows
unknown error: DevToolsActivePort file doesn't exist
You can see that the code above has all the options added.
I referred stackoverflow already answered here, but that doesn't seems to be working
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
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/
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.
I am using ant to run my selenium test, and I have this message (see pic):
[junit] Error
[junit] Starting ChromeDriver (v2.xxxxx) on port xxxx
I tried the following properties but without success :
options.addArguments("--disable-logging");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--silent");
I can disable this message? it's possible ?
I suggest:
ChromeOptions chromeOptions = setupChromeOptions();
System.setProperty("webdriver.chrome.logfile", "\\path\\chromedriver.log");
System.setProperty("webdriver.chrome.driver", "\\path\\chromedriver.exe");
System.setProperty("webdriver.chrome.args", "--disable-logging");
System.setProperty("webdriver.chrome.silentOutput", "true");
driver = new ChromeDriver(chromeOptions);
because
1) This way works for me and
2) the often-reccomended ChromeDriverService.Builder() throws a compile error for me.
This works for me with the following config
selenium-chrome-driver-2.48.2.jar
chromedriver 2.20
selenium-java-2.48.2.jar
We need to pass --silent argument to chromedriver to stop console message. We can achieve this using 'withSilent(true)' method
Launch chromedriver using chromedriverservice as shown in below sample code
Sample Code:
ChromeDriverService cdservice=new ChromeDriverService.Builder().usingDriverExecutable(new File("/path/to/chromedriver.exe"))
.withLogFile(new File("/path/to/chromedriver.log"))
.withSilent(true)
.usingAnyFreePort()
.build();
WebDriver driver = new ChromeDriver(cdservice);
driver.get("http://www.google.com");