import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Webdriver {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
//System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver.exe");
//WebDriver driver = new ChromeDriver();
driver.get("https://maps.mapmyindia.com");
Thread.sleep(2000);
driver.findElement(By.id("auto")).sendKeys("TCS");
Thread.sleep(2000);
driver.findElement(By.id("auto_geo")).click();
When i run this code on eclipse luna there is an error: Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
new FirefoxDriver(DesiredCapabilities caps);
is deprecated, use
FirefoxOptions options = new FirefoxOptions();
options.setCapability("marionette", false);
WebDriver webDriver = new FirefoxDriver(options);
and you are good to go
Another possible cause is the outdated Firefox version.
I upgraded the version and it works fine!
I could open the browser only setting options.setCapability("marionette", true);
, then in the open window I upgraded through the "About Firefox" dialog. Then you have to remove the line about marionette
.
Probably the one I had was only going to work with marionette
while we are trying to use it with geckodriver
, which has a different protocol. Anyone who knows more than me can confirm or deny!
SessionNotCreatedException
extends WebDriverException
and is a RuntimeException
which indicates that a session could not be created.
The possible causes of a new session not getting created are as follows :
JDK
, Selenium
, WebDriver
and Web Browser
versions.GeckoDriver
or Marionette
by the new session which previous session have't released yet.CPU
Physical Memory
Swap Memory
Disc Cache
Network Bandwidth
OS chores
within the system.I don't see any coding issue in your code block as such.
The simple solution would be as follows :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With