user8305604
user8305604

Reputation:

selenium not get http

I tried below code in eclipse. When I run this code firefox will open but driver.get("https://www.easybooking.lk/login"); not working. Please help me in resolving this error

package login;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class easylogin {

    //public static void main(String[] args) {
        // TODO Auto-generated method stub
        public static void main(String[] args) throws InterruptedException {
            //Object webdriver;
            System.setProperty("webdriver.gecko.driver", "D:\\jjpppp\\geckodriver-v0.17.0-win64/geckodriver.exe");

            WebDriver driver = new FirefoxDriver();
            driver.manage().window().maximize();
            driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
            driver.get("https://www.easybooking.lk/login");  

I am getting below error. How can I fix this? I added selenium firefox drivers

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:872)
    at login.easylogin.main(easylogin.java:20)

Upvotes: 0

Views: 108

Answers (5)

Akshay Hendre
Akshay Hendre

Reputation: 29

try putting implicit wait after navigating to web address.

public static void main(String[] args) {
    // TODO Auto-generated method stub
    public static void main(String[] args) throws InterruptedException {
        //Object webdriver;
        System.setProperty("webdriver.gecko.driver", "D:\\jjpppp\\geckodriver-v0.17.0-win64\\geckodriver.exe");

        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("https://www.easybooking.lk/login");
        driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); 

this will help you to wait till web-page loads next find element.

Upvotes: 1

RArora
RArora

Reputation: 234

The issue is because your browser and geckodriver are not compatible.

I tried with latest firefox version(56.0) and geckodriver 18. It worked fine.

Then I tried firefox(56.0) and geckodriver 17. It gave me similar issue.

So better use latest firefox and geckodriver.

Upvotes: 2

GHOST
GHOST

Reputation: 453

driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);

remove this and try

Upvotes: 0

Shoaib Akhtar
Shoaib Akhtar

Reputation: 1403

As per error message, it seems there is some problem in implicitlyWait. It does not seems to be working. Just comment this code and check once

driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);

Upvotes: 3

Allan
Allan

Reputation: 12438

Have you tried to change the path to your driver in the following way:

D:\\jjpppp\\geckodriver-v0.17.0-win64\\geckodriver.exe

You might also have a look at the following change in order to be sure that your DOM is completely loaded:

WebDriverWait logWait = new WebDriverWait(driver, 10);
logWait.until(ExpectedConditions.presenceOfElementLocated(by));  
driver.findElement(...)

Upvotes: 2

Related Questions