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)
{
this.driver=driver;
}
@FindBy(how=How.NAME,using="username")
@CacheLookup
WebElement username;
@FindBy(how=How.NAME,using="password")
@CacheLookup
WebElement password;
@FindBy(how=How.CLASS_NAME,using="button")
@CacheLookup
WebElement button;
@FindBy(how=How.LINK_TEXT,using="Forgot Password")
@CacheLookup
WebElement fp;
public void login_Doc(String uid,String pas)
{
username.sendKeys(uid);
password.sendKeys(pas);
button.click();
}
}
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
{
@Test
public void chechValidUser()
{
System.setProperty("firefox.webdriver.marionette","pathToGeckodriver");
WebDriver driver=BrowserFactory.startBrowser("firefox","54.68.159.876/docmgr");
LoginPage login=PageFactory.initElements(driver,LoginPage.class);
login.login_Doc("jgsdg","123");
}
}
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)
{
if(browsName.equals("firefox"))
{
driver=new FirefoxDriver();
}
driver.manage().window().maximize();
driver.get(url);
return driver;
}
}
Error is:
FAILED: chechValidUser
org.openqa.selenium.WebDriverException: Target URL 54.68.159.204/docmgr 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: '127.0.1.1',
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 [{
applicationCacheEnabled=true,
rotatable=false,
handlesAlerts=true,
databaseEnabled=true,
version=45.0,
platform=LINUX,
nativeEvents=false,
acceptSslCerts=true,
webStorageEnabled=true,
locationContextEnabled=true,
browserName=firefox,
takesScreenshot=true,
javascriptEnabled=true,
cssSelectorsEnabled=true}]
Session ID: 992a8a4c-efe1-462f-a656-2f8faadf4c06