I am trying to automate an app where i need to fill customer information form. In this form some text fields are visible and some text fields are hidden, which become visible only after scroll. All elements having same resource:id. So I am trying to fetch all elements into List like this
List < WebElement > allTextFields = driver.findElements(By.id(“Unique Id Value”) ;
But problem is I am getting WebElement values of only visible text fields and Hidden one are not picked by this command.
So lets say if I have 18 elements out of which 6 are visible and reset are visible only after scrolling(Next 6) and againg scrollng(last 6) and getting webelement values of visible 6 elements.
Need your thoughts/input on how to overcome this problem.
List < WebElement > allTextFields = driver.findElements(By.id(“Unique Id Value”)
Above statement will fill in the list with list of visible elements. After scroll down you need to add those elements into the list again. You will have to go like this:
Get the first and last visible elements position coordinates (X, Y)
Swipe from last visible element to first visible element
Get the visible elements again
Append these elements (add into list) - make sure no duplicates are added
Repeat this procedure until first and last visible elements are same and stop scrolling
You can maintain two separate lists. One is to have visible elements in it and second one is being used to fill in non-duplicate elements list of complete form which shall be used to fill the form.
Thank you Umar, Appreciate your help.
it helped me to some extent.
But there is one more problem, Since id identifiers for all text fields are same , it is overlapping with already filled one text fields, and entering values in already filled ones.
Is there is any to get track of each text field separately. Please suggest how to over come this problem.
You could use the getText method to retrieve the text that’s entered into the fields, and then start filling in fields again after finding a field that has not yet been filled in.