Getting this Error : java.lang.IllegalArgumentException: Keys to send should be a not null CharSequence. How to resolve this issue?
POM design model used using TestNG Framework
Please find out the below code snippets for both the java classes I have added
The below code snippet is LoginPageTest Java Class
package com.crm.qa.testcases;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.crm.qa.base.TestBase;
import com.crm.qa.pages.HomePage;
import com.crm.qa.pages.LoginPage;
public class LoginPageTest extends TestBase{
LoginPage loginpage;
HomePage homepage;
public LoginPageTest() {
super();
}
@BeforeMethod
public void setup() {
initialization();
loginpage = new LoginPage();
}
@Test(priority=1)
public void loginpagetitletest() {
String title = loginpage.ValidatePageTitle();
Assert.assertEquals(title, "Login");
}
@Test(priority=2)
public void loginTest()
{
homepage = loginpage.login(prop.getProperty("emailId"),prop.getProperty("password"));
}
@AfterMethod
public void Teardown() {
driver.quit();
}
}
And the below snippet is LoginPage Java Class
package com.crm.qa.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import com.crm.qa.base.TestBase;
public class LoginPage extends TestBase {
//Page Factory - object repository:
@FindBy(id = "li_myaccount")
WebElement myaccountbtn;
//*[@id="li_myaccount"]/ul/li[1]/a
@FindBy(xpath = "//a[contains(text(), 'login')]")
WebElement loginbtn;
@FindBy(name = "username")
WebElement username;
@FindBy(name = "password")
WebElement password;
@FindBy(xpath = "//*[@id='loginfrm']/button")
WebElement lgnbtn;
@FindBy(xpath = "//a[contains(text(), 'Sign Up')]")
WebElement Signupbtn;
//Initialize the Page Objects
public LoginPage() {
PageFactory.initElements(driver, this);
}
//Actions
public String ValidatePageTitle() {
return driver.getTitle();
}
public HomePage login(String un, String pwd) {
username.sendKeys(un);
password.sendKeys(pwd);
myaccountbtn.click();
loginbtn.click();
return new HomePage();
}
} package com.crm.qa.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import com.crm.qa.base.TestBase;
public class LoginPage extends TestBase {
//Page Factory - object repository:
@FindBy(id = "li_myaccount")
WebElement myaccountbtn;
//*[@id="li_myaccount"]/ul/li[1]/a
@FindBy(xpath = "//a[contains(text(), 'login')]")
WebElement loginbtn;
@FindBy(name = "username")
WebElement username;
@FindBy(name = "password")
WebElement password;
@FindBy(xpath = "//*[@id='loginfrm']/button")
WebElement lgnbtn;
@FindBy(xpath = "//a[contains(text(), 'Sign Up')]")
WebElement Signupbtn;
//Initialize the Page Objects
public LoginPage() {
PageFactory.initElements(driver, this);
}
//Actions
public String ValidatePageTitle() {
return driver.getTitle();
}
public HomePage login(String un, String pwd) {
username.sendKeys(un);
password.sendKeys(pwd);
myaccountbtn.click();
loginbtn.click();
return new HomePage();
}
}`
prop.getProperty("emailId")orprop.getProperty("password")is null, by the looks of it.