Hi,
I am trying to setup a simple Selenium project up but I can't get the initial setup right. My current code is:
import java.util.concurrent.TimeUnit;import org.openqa.selenium.*;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.firefox.FirefoxOptions;publicclass webdriverdemo {publicstaticvoid main(String[] args){System.setProperty("webdriver.gecko.driver","geckodriver");FirefoxOptions firefoxOptions =newFirefoxOptions();
firefoxOptions.setCapability("marionette",true);WebDriver driver =newFirefoxDriver(firefoxOptions);
driver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);
driver.navigate().to("http://www.calculator.net/");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*[@id = 'menu']/div[3]/a")).click();
driver.findElement(By.xpath(".//*[@id = 'menu']/div[4]/div[3]/a")).click();
driver.findElement(By.id("cpar1")).sendKeys("10");
driver.findElement(By.id("cpar2")).sendKeys("50");
driver.findElement(By.xpath(".//*[@id = 'content']/table/tbody/tr[2]/td/input[2]")).click();String result = driver.findElement(By.xpath(".//*[@id = 'content']/p[2]/font/b")).getText();System.out.println("The result is "+ result);
driver.close();}}
And the error I'm getting is:
1510139780110 geckodriver INFO geckodriver 0.19.11510139780119 geckodriver INFO Listening on 127.0.0.1:34481510139781051 mozrunner::runner INFO Running command:"/usr/lib64/firefox/firefox""-marionette""-profile""/tmp/rust_mozprofile.KnF05xRcbAZX"1510139784365Marionette INFO Listening on port 2828
kf5.kio.core:RefillingKProtocolInfoFactory cache in the hope to find "ircs"
kf5.kio.core:RefillingKProtocolInfoFactory cache in the hope to find "mailto"
kf5.kio.core:RefillingKProtocolInfoFactory cache in the hope to find "irc"Exception in thread "main" org.openqa.selenium.WebDriverException: connection refusedBuild info: version:'3.7.1', revision:'8a0099a', time:'2017-11-06T21:01:39.354Z'System info: host:'linux-m2zi.suse', ip:'Unknown', os.name:'Linux', os.arch:'amd64', os.version:'4.4.92-31-default', java.version:'1.8.0_144'Driver info: driver.version:FirefoxDriver
remote stacktrace: stack backtrace:0:0x4edb3c- backtrace::backtrace::trace::hc4bd56a2f176de7e1:0x4edb72- backtrace::capture::Backtrace::new::he3b2a15d39027c462:0x440ac8- webdriver::error::WebDriverError::new::ha0fbd6d1a1131b433:0x447ba9- geckodriver::marionette::MarionetteHandler::create_connection::hf0532ddb9e1596844:0x428570-<webdriver::server::Dispatcher<T, U>>::run::h2119c674d7b881935:0x4029b9- std::sys_common::backtrace::__rust_begin_short_backtrace::h21d98a9ff86d4c256:0x40be65- std::panicking::try::do_call::h5cff0c9b18cfdbba7:0x5e6a6c- panic_unwind::__rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:998:0x41eb22-<F as alloc::boxed::FnBox<A>>::call_box::h413eb1d9d9f1c4739:0x5df13b- alloc::boxed::{{impl}}::call_once<(),()>
at /checkout/src/liballoc/boxed.rs:692- std::sys_common::thread::start_thread
at /checkout/src/libstd/sys_common/thread.rs:21- std::sys::imp::thread::{{impl}}::new::thread_start
at /checkout/src/libstd/sys/unix/thread.rs:84
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
at com.seltri.webdriverdemo.main(webdriverdemo.java:14)
I
have tried a couple of things but I'm pretty new to this stuff so I wasn't really able to solve it. What can I do to fix this? I've also tried using RemoteWebDriver but that also didn't work. I haven't tested with chrome etc.
I am using OpenSUSE Linux with Firefox 52.
Thanks & Regards
Hari