I am currently using Selenium jar version 3.3.1 with Firefox 43.0.4 and Eclipse Mars.2 Release (4.5.2).
When I execute the following code:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Links_Count_List {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:\\Users\\daniel\\Desktop\\Selenium\\geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
//WebDriver driver = new MarionetteDriver(capabilities);
WebDriver driver=new FirefoxDriver();
driver.get("http://newtours.demoaut.com/");
WebElement link=driver.findElement(By.linkText("Home"));
System.out.println(link.getText());
//link.click();
List<WebElement> allLInks=driver.findElements(By.tagName("a"));
System.out.println("Total number of links are "+allLInks.size());
for(int i=0;i<allLInks.size();i++){
System.out.println(allLInks.get(i).getText());
}
}
}
I encountered the following error message. I would appreciate any assistance.
Console
1492082184399 geckodriver INFO Listening on 127.0.0.1:10506
1492082185052 mozprofile::profile INFO Using profile path C:\Users\daniel\AppData\Local\Temp\rust_mozprofile.opDtseG9ymZk
1492082185054 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args []
1492082185062 geckodriver::marionette INFO Connecting to Marionette on localhost:59371
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}], required capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}]
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'INFONOVUM-39', ip: '192.168.10.66', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
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:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
at Links_Check.Links_Count_List.main(Links_Count_List.java:18)