So currently I have this codes:
//WebElement VariableName is to declare the name of the WebElement
//String Id is the Id of the element that you want to send values to
//String valuesToAddIn is the value that you want to enter into the webpage
//String stringNameToCompareLater is the variable to store the values of the input, that you just entered.
public void AddInValueAndCompareString(WebElement VariableName ,String Id , String valuesToAddIn, String stringNameToCompareLater)
{
VariableName = driver.findElement(By.id(Id));
VariableName.sendKeys(valuesToAddIn);
EnsureUserInputByID(Id);
stringNameToCompareLater = VariableName.getText();
}
What I would like to do, is to get the string that I have just entered using selenium and store it in a variable.
However, it is going to be very troublesome, if you were to add in these lines for every part of the code.
So my implementation of the above code is as follows:
AddInValueAndCompareString(CourseFeePaid,"courseFeePaid","123.90","courseFeePaidCompare");
However, the CourseFeePaid is actually giving me the error of
CourseFeePaid cannot be resolved to a variable
So is it that I cannot declare the name of the WebElement in a parameter, or is there any other errors in the code.
The ultimate deliverable that i want to get is:
- The values are added into the textboxes
- The values are stored inside of a variable, so as to do comparison later.