Hi,
When I use the below statement, it always search from the top of the screen to search for the matching text.
UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches("" + selector + “”).instance(0))"));
Consider a scenario where there two elements Element1 and Element2 displaying invisible before scrolling and Element1 is having matching text of ‘permission’ and Element2 is having matching text of ‘Submit’.
When I use the command for Element1 as below, it searches from the top of the screen for the text ‘permission’ and if finds the match, it stops there.
UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches("" + “permission”+ “”).instance(0))"));
And now, when I use the command for Element2 as with matching text ‘Submit’, it again scrolls to the top to find the matching for the text ‘Submit’.
UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches("" + “Submit”+ “”).instance(0))"));
When Element1 is already found, shouldn’t the search for ‘Element2’ start from the position after ‘Element1’?
If the command using textMatches is made to work like always searching from the top, is there any alternative best approach to scroll to any particular element?
I already tried the below method also but did not find it effective way:
org.openqa.selenium.Dimension size1 = driver.manage().window().getSize();
int x1 = size1.getWidth() / 2;
int starty1 = (int) (size1.getHeight() * 0.70);
int endy1 = (int) (size1.getHeight() * 0.10);
driver.swipe(x1, starty1, x1, endy1, 3000);
Please let me know your responses.