I am automating a Tablet application using Appium + Java. In a screen, I have 100+ fields (Textbox + Dropdown) to automate which has scroll view.
To automate those 100+ fields, I have listed down all the IDs(of those textbox and dropdown in that screen) along with the test Cases and Test Data in separate Excel sheets. My code runs in a loop, picks Test Case, its Data and relevant ID and executes. So, my code looks like:
loop : for(int j = 1; j <= fieldCount; j++)
{
objElementRepositoryLibrary.setElementRepositoryDataLibrary(j);
switch(ElementRepositoryLibrary.getElementType()) {
case "AutoPopulated":
System.out.println(ElementRepositoryLibrary.getElementValue() + " is Autopopulated");
break;
case "Dropdown":
ElementOperation.checkElementState(qdeDriver, ElementRepositoryLibrary.getLocator(), ElementRepositoryLibrary.getElementValue());
if(ElementOperation.ElementAcceess.equals(false))
System.out.println(ElementRepositoryLibrary.getElementValue() + " is disabled");
else
objElementOperation.dropdownSelectListner(qdeDriver, ElementRepositoryLibrary.getLocator(), ElementRepositoryLibrary.getElementValue(), field[0][j-1]);
break;
case "Button":
ElementOperation.checkElementState(qdeDriver, ElementRepositoryLibrary.getLocator(), ElementRepositoryLibrary.getElementValue());
if(ElementOperation.ElementAcceess.equals(false)) {
System.out.println(ElementRepositoryLibrary.getElementValue() + " is disabled");
break loop;
}
else if(field[0][j-1].equals(""))
System.out.println("Checking for Null value");
else if(field[0][j-1].equals("Yes") && ElementRepositoryLibrary.getFieldName().equals("QR Scanner"))
objElementOperation.buttonClickListner(qdeDriver, ElementRepositoryLibrary.getLocator(), ElementRepositoryLibrary.getElementValue());
else if(ElementRepositoryLibrary.getFieldName().contains("Capture Document"))
objElementOperation.captureDocument(qdeDriver, ElementRepositoryLibrary.getLocator(), ElementRepositoryLibrary.getElementValue());
break;
default :
objElementOperation.textboxSetListner(qdeDriver, ElementRepositoryLibrary.getElementType(), ElementRepositoryLibrary.getLocator(),
ElementRepositoryLibrary.getElementValue(), field[0][j-1]);
break;
}
}
ISSUE: After filling few(say 7) fields, it is giving me NoSuchElementException
because I have to scroll in the screen to move to the next fields(It goes like: screen contains 7 fields & you have to scroll to view the fields below and automator will nor recognize the element
until it is viewed in the screen).
What I had tried is, I did catch
for NoSuchElementException
and performed Scroll operation. But it is not the proper way to do because if the element which has been searched is not present in actual, then also it will catch NoSuchElementException
and perform scroll operation.
Suggest some good way to eliminate this issue. Let me know if any detail needed.