which chromedriver version supports electron app? - java

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.

Related

How to enable remote debugging with chrome, selenium, chromedriver on mac

I want to re-use an existing chrome browser that's running on my mac.
From the internet it looks like I need to open chrome with arguments then run the java code and set the port number. Unfortunately I still get errors.
Open chrome on port 9222 from terminal:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port-9222 --user-data-dir="~ChromeProfile"
Java code in program to connect to chrome:
WebDriver dr = null;
location = "/Users/xx/Downloads/chromedriver";
System.setProperty("webdriver.chrome.driver", location);
ChromeOptions options = new ChromeOptions();
//options.addArguments("--remote-debugging-port=9222");
//options.setExperimentalOption("--remote-debugging-port", "localhost:9222");
options.setExperimentalOption("debuggerAddress", "localhost:9222");
dr = new ChromeDriver(options);
dr.navigate().to(myLink);
Netbeans keeps opening a random port and not 9222;
Starting ChromeDriver 9X.X.XXXX.XX (8c61b7e2989f2990d42f859cac71319137787cce-refs/branch-heads/4515#{#306}) on port 4188
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
What am I doing wrong?

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed using ChromeDriver Selenium in Jenkins on Ubuntu 18.04

Chrome is not stable on my Jenkins. When I run build 5 times, it runs 1 - 2-time success, and the other 3 times I have the above error.
Snapshot of the error:
Code for Chrome :
ChromeOptions options = new ChromeOptions();
System.setProperty("webdriver.chrome.driver","/usr/local/bin/chromedriver");
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
driver = new ChromeDriver(options);
driver.get("https://mywebsite.com");
Some steps I have already taken :
Provided 777 permission to google chrome and chrome driver
Set : Start Xvfb before the build, and shut it down after to True in Jenkins build setting
ChromeDriver 81.0.4044.69
Google Chrome 81.0.4044.129
Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-99-generic x86_64)
This error message...
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Deep dive
Looking into the snapshot of the error stacktrace you have provided, though you mentioned about using ChromeDriver 81.0.4044.69 and Google Chrome 81.0.4044.129, still it appears there is a mismatch between the versions of the different binaries you are using, possibly Chrome browser is not installed at the default location within your system or due to JDK mismatch. Additionally, ChromeDriver 81.0.4044.69 (2020-03-17) was a bit unstable which was replaced by ChromeDriver 81.0.4044.138 (2020-05-05)
However, the server i.e. ChromeDriver expects you to have Chrome installed in the default location for each system as per the image below:
1For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
You can find a detailed discussion in What is default location of ChromeDriver and for installing Chrome on Windows
Solution
In case you are using the Chrome executable in a non-standard location you have to override the Chrome binary location as follows:
Code based solution:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setBinary('/usr/bin/google-chrome'); //chrome binary location
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
//execute the remaining steps
driver.quit();
Additional considerations- Ensure the following:
JDK is upgraded to current levels JDK 8u251.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v81.0.4044.138 level.
Chrome is updated to current Chrome Version 81.0.4044.138 level. (as per ChromeDriver v80.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium?
Running Chromedriver on Ubuntu Server headlessly

Facing issue regarding Selenium(with java) and Firefox connectivity

Error: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Before all scripts were working fine..but now every script has stopped working.
I have updated Selenium version 3.0.1.(updated jar files), updated Firefox version 52.0.2 ...java version 8.
Please suggest what I am missing?
with Geckodriver version v0.15 , you have to use selenium 3.3.1
You would need to provide firefox binary location. One way of doing it is by the below code -
FirefoxOptions options = 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/
For Selenium 2.x later versions need to maintain geckodriver for firefox browser and if you find same issue then add binary path to your driver instance and try again.
Reference:
selenium 2.53.0 with firefox 46

Having issues with firefox driver or chrome driver for selenium

For ex my chrome when dropped in the commpand prompt gives me the path
- /Applications/Google\ Chrome.app
I set
System.setProperty("webdriver.chrome.driver", "/Applications/Google/Chrome.app");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
But it doesnt work, same with firefox. I used a lot of suggestions already given but none seems to work. Can someone pls let me know if there is something to be added?
Why have you used "/Applications/Google/Chrome.app". You would need to provide the path of the driver only, not the browser. Below is the code for Firefox, but you would need to download and configure GeckoDriver (for latest version of FF and Selenium 3.x)
public class FirefoxTest {
#Test
public void FirefoxTest_Test1() {
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
}
Check this link for complete details for downloading and setup of Geckodriver with Firefox - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For Chrome: Need to Download fresh Chrome Driver from http://chromedriver.storage.googleapis.com/index.html?path=2.24/
and mention local system path up to chomedriver.exe
System.setProperty("webdriver.chrome.driver","G:\\ravik\\Ravi-Training\\Selenium\\Drivers\\cd\\chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeDriver d1 = new ChromeDriver(capabilities);
For FF: if your firefox version is latest(46.0 or above) then user geckodriver along with selenium 2.53.0 jar files. download geckodriver form https://github.com/mozilla/geckodriver/releases and then save it as "wires" in your local system. mention local system path up to wires.
System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
WebDriver driver = new MarionetteDriver();
Hope this could be helpful.
The easiest way to use chrome driver is.. download and place the driver into the bin folder of your project. no need to set the path of the driver location

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