Getting java.lang.IllegalArgumentException: Keys to send should be a not null CharSequence

378 views
Skip to first unread message

sandy

unread,
Apr 27, 2023, 12:46:42 AM4/27/23
to Selenium Users
Hi All ,

Iam getting the below error:
java.lang.IllegalArgumentException: Keys to send should be a not null CharSequence

Reason : Stored value returns null instead of the text

Created method to store the value as seen below:

public String checkcreatedSampleNoentered() throws InterruptedException {
Thread.sleep(3500);
String numberfromsample = "";
{
samplenos= "//input[@formcontrolname='sample']";
Thread.sleep(500);
WebElement samplenoteno = driver.findElement(By.xpath(samplenos));
numberfromsample = samplenoteno.getAttribute("value");
System.out.println("Print the sampenumber:"+numberfromsample);

}
return numberfromsample;
}

Then i get the number and store the number:
public String getsampleNo() throws InterruptedException {
return checkcreatedSampleNoentered();
}
public void storeSampleNo() throws InterruptedException {
samplenos = checkcreatedSampleNoentered();

}

Then in CommonUse Util i have created the getters and setters for this:

public class CommonUseUtil {
public static String samplenos;
public static String getSamplenos() {
return samplenos;
}

public void setSamplenos(String samplenos) {
CommonUseUtil.samplenos = samplenos;
}

And then i call this stored value in the method where i need to key in the text:

apputils.doSendKeys(palletNo,CommonUseUtil.getSamplenos());
in this line of code getting above error and it is bz the sampleno is null

Any leads would be helpful as iam not able to find a solution
Reply all
Reply to author
Forward
0 new messages