I am using selenium with page factory method to automate a login page. An error came when I try to run my code.

My complete code is..

package com.docmgr.Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.WebElement;
public class LoginPage
    WebDriver driver;
    public LoginPage(WebDriver driver)
WebElement username;
WebElement password;
WebElement button;
@FindBy(how=How.LINK_TEXT,using="Forgot Password")
WebElement fp;
public void login_Doc(String uid,String pas)

package com.docmgr.TestCases;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;

import com.docmgr.Pages.LoginPage;

import Helper.BrowserFactory;

public class LoginTest 
    public void chechValidUser()
WebDriver driver=BrowserFactory.startBrowser("firefox","");
LoginPage login=PageFactory.initElements(driver,LoginPage.class);


package Helper;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class BrowserFactory
    static WebDriver driver;
    public static WebDriver startBrowser(String browsName,String url)
            driver=new FirefoxDriver();

        return driver;


Error is:

FAILED: chechValidUser
org.openqa.selenium.WebDriverException: Target URL is not well-formed.
Command duration or timeout: 27 milliseconds
Build info:
 version: 'unknown',
 revision: '2aa21c1',
 time: '2016-08-02 14:59:43 -0700'
System info:
 host: 'naveen-Inspiron-3542',
 ip: '',
 os.name: 'Linux',
 os.arch: 'amd64',
 os.version: '4.4.0-45-generic',
 java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{
Session ID: 992a8a4c-efe1-462f-a656-2f8faadf4c06

  • Have you added the jar files properly to your test project? Nov 10, 2016 at 10:10
  • @TESTasy ya sure
    – user21268
    Nov 10, 2016 at 10:11
  • @TESTasy Error I mentioned there where I need to put this command System.setProperty("firefox.webdriver.marionette","pathToGeckodriver");
    – user21268
    Nov 10, 2016 at 10:12
  • Usually its right before you initialize your driver. Nov 10, 2016 at 10:22
  • @TESTasy Please tell me the correct path
    – user21268
    Nov 10, 2016 at 10:25

1 Answer 1


If I understand this correctly, You should not put "pathToGekoDriver" in your code. There you should mention the path where the gecko driver is installed like:

System.setProperty("firefox.webdriver.marionette", "E:\\Softwares\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
  • Hai, Everyone I got the error. I didn't add the protocol. http://...... and Thank you every one for the contribution
    – user21268
    Nov 11, 2016 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.