I am receiving the following exception for my java code. All I want to do is open up a chrome browser. I have downloaded the proper chrome driver and stuck it in my google chrome folder under program files x86. Right now what happens is, the browser opens and then immediately says that the program has stopped working and then It throws the exception once I click exit on the window.
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'W7LPC01TDFU', ip: '10.95.7.58', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
here is my code so far
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class mainTester {
public static void main(String[] args) throws InterruptedException{
setUp();
}
public static void setUp() throws InterruptedException {
// Optional, if not specified, WebDriver will search your path for chromedriver.
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com/xhtml");
Thread.sleep(5000); // Let the user actually see something!
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("ChromeDriver");
searchBox.submit();
Thread.sleep(5000); // Let the user actually see something!
System.out.println("Finished");
driver.quit();
}
}
Do you know what version of Chrome you are using? Chances are the latest since Google likes to autoupdate. You should be using the latest version of Chromedriver. The traceback you posted says you are using version 2.20 (Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239). The latest is 2.25 which Supports Chrome v53-55
Related
I'm using Selenium Web driver, however, I am preloading a browser by setting the debuggerAddress. I connect through a specified port. I had this working great. Suddenly, it's stopped working. I'm not quite sure what the issue is.
public void launchBrowser() throws InterruptedException {
try {
// Set file path of chrome driver
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// Start chrome driver with existing chrome browser
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("debuggerAddress","localhost:1250");
// Create object
driver = new ChromeDriver(options);
// Write to console where we are
System.out.println(driver.getCurrentUrl());
}
catch(Exception e) {
console("JacksClass.java","launchBrowser()", "Exception: " + e);
}
}
Before I run the script. I start the Chrome browser with this command in CMD
start chrome --remote-debugging-port=1250
After launching the browser from CMD successfully. Then running the code. I get the following exception after around 1-2 minutes.
JacksClass.java - launchBrowser() : Exception: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc'
System info: host: 'DESKTOP-5H32IOI', ip: '192.168.1.53', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: ChromeDriver
All of this was working great a month ago. I have the chrome driver installed in the same location.
Finally got it to work. Firstly I tried to access the open port in another browser.
Typing localhost:1250 into the URL bar.
It could not connect. So there clearly was an issue with that port. I have tried many different ports but still had the same issue.
I finally tried port 1258 and then double-checked it with the test outlined above. Typing localhost:1258 into another browser proved the port was active.
Then my program worked as well! How strange! Glad it's working now :)
We have a set of Selenium auto tests that work with Chrome/Firefox/Edge (pre Chromium Edge). We would like to be able to run the set test suite against the latest edge.
Selenium (Java) - 4.0.0-alpha-4
Edge - 79.0.309.71
I've tried various combinations of the below setup
System.setProperty("webdriver.edge.edgehtml", "false");
System.setProperty("webdriver.edge.driver", "path\to\msedgedriver.exe");
System.setProperty("webdriver.chrome.driver", "path\to\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setBinary("path\to\msedgedriver.exe");
driver = new EdgeDriver();
Each time gives the following error
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-4', revision: 'c2d955b49e'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_162'
Driver info: driver.version: EdgeDriver
Has anyone got this working?
I test with Microsoft Edge(Chromium) Beta version 79.0.309.43 and the same version of Microsoft Edge(Chromium) WebDriver (You could download the webdriver from here) and it works. You could refer to the code below and change the path to your owns:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
WebDriver driver = new ChromeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
Also please remember to have the location of Edge Beta and msedgedriver.exe on your PATH.
Not sure if this will be relevant for everyone, but I have fixed it myself by doing the following...
The version of edge is Version 79.0.309.71 (Official build) (64-bit) and i assumed the correct driver was the the 64 bit driver from the microsoft site.
HOWEVER, I then tried the 32 bit driver and it worked as expected...
System.setProperty("webdriver.edge.driver", "path\to\msedgedriver_32.exe");
driver = new EdgeDriver();
I am pretty new to Selenium world. I have been stuck with this code of opening a basic facebook page and it keeps throwing an error saying:
Starting ChromeDriver 78.0.3904.105
(60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904#{#877})
on port 8852 Only local connections are allowed. Please protect ports
used by ChromeDriver and related test frameworks to prevent access by
malicious code. Exception in thread "main"
org.openqa.selenium.WebDriverException: unknown error: cannot find
Chrome binary Build info: version: '3.141.59', revision: 'e82be7d358',
time: '2018-11-14T08:25:48' System info: host: 'ATLMD2226268', ip:
'10.7.0.108', os.name: 'Windows 10', os.arch: 'amd64', os.version:
'10.0', java.version: '1.8.0_211'
Code I am using is:
package NewPackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class MyClass {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\vaaggarw\\Downloads\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files (x86)\\Google Chrome (Local)\\chrome.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://www.facebook.com";
String tagName = "";
driver.get(baseUrl);
tagName = driver.findElement(By.id("email")).getTagName();
System.out.println(tagName);
driver.close();
System.exit(0);
}
}
make sure all selenium jars are not missing in your project. If not delete them anyway and add new jars from fresh download
clean your project
as pcalkins advises, use the chrome options propertly
I am fairly new to selenium and trying to invoke the Firefox browser using the following java code.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class google {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "/Users/gowtham/Desktop/Selenium/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
Thread.sleep(1000);
driver.quit();
}
}
When I run the above code, I get the following exception on my console.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#7d70d1b1, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile#2a742aa2}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '86a5d70', time: '2017-02-16 07:47:51 -0800'
System info: host: 'system', ip: 'fe80:0:0:0:2acf:e9ff:fe19:261%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_45'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:263)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:122)
at HelloWorls.google.main(google.java:11)
I have firefox v52.0 installed on my machine.
Please share your thoughts on this issue.
I can't add comments so far, so post the way to resolve this problem here.
Indeed, gecko driver version needs to be downgraded.
For those, who are using 'bonigarcia-webdrivermanager', add driver version explicitly before instantiating FirefoxDriver:
FirefoxDriverManager.getInstance().setup("0.14.0");
I'm very new to Selenium. Below given is my first test script.
Question: Does it require selenium server to test a local website (which is hosted in the same machine as the test scripts being run).
Also tried executing the same script from Internet Explorer also, still getting the same.
It just opens the browser and closes(because of finally block) it.
import org.openqa.selenium.chrome.ChromeDriver;
public class TestScript {
/**
* #param args
* #throws InterruptedException
*/
public static void main(String[] args) {
ChromeDriver driver = null;
try
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user1\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
driver = new ChromeDriver();
System.out.println("Opening the Browser");
driver.get("http://localhsot:5080/myWebSite/8450191#");
System.out.println("Open the Browser");
System.out.println("");
System.out.println("Title" +driver.getTitle());
}
catch (Exception ie)
{
ie.printStackTrace();
}
finally
{
System.out.println("Quitting the Browser");
driver.close();
driver.quit();
}
}
}
Exception: Below is the exception I am getting while executing from the Eclipse:
[2820:6204:36503609:ERROR:gpu_info_collector_win.cc(93)] Can't retrieve a valid WinSAT assessment.
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: '01hw535163', ip: '10.72.15.53', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:112)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:162)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:108)
at com.seic.scripts.TestScript.main(TestScript.java:16)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: '01hw535163', ip: '10.72.15.53', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 6 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:37571/status] to be available after 20009 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 8 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 9 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:228)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 10 more
Quitting the Browser
Exception in thread "Main Thread" java.lang.NullPointerException
at com.scripts.TestScript.main(TestScript.java:31)
Chrome Version: 21.0.1171.0
OS: Windows 7 64 bit.
Selenium Web Driver version:2.39.0
You are getting a little confused about what you need to point Selenium to.
Here:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user1\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
This setting, webdriver.chrome.driver is a setting that Selenium will read to find out where the ChromeDriver is located, not the actual Chrome installation.
https://code.google.com/p/selenium/wiki/ChromeDriver
You must download the ChromeDriver and where it is located should be what you pass in for the webdriver.chrome.driver property.
I imagine it's the same reason when you try with IE, it also requires a driver which I guess you don't have:
https://code.google.com/p/selenium/wiki/InternetExplorerDriver
In terms of whether you need a "server" -> for your tests, no, you are not running them remotely. Once you decide to run them remotely (i.e use the RemoteWebDriver instead of ChromeDriver) then you will need the Selenium server.
I would recommend instead of using System.setProperty() to put your drivers in the same folder and point to that folder in System Variables Path. Then you don't need to point to it at all in code and updating your driver won't require a code rewrite.