This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
22 / 24
Dec 2017

Is it possible to share ipa file ? I will not share with any one and if able to create working code I will delete it.
Actually I tried scroll of iOS UICatalog using coordinates it didn't worked.
But if I pass web element to Touch Actions it worked.

@amitjaincoer191 Here is my scenario

Scenario 1:-

  1. There are 20 article in the page
  2. Only 5 articles are displayed. Other articles are displayed when you scroll
  3. How can i scroll with x and y co-ordinates and find an expected article. I want to reach 20th article and click it.
  4. This is list of articles page, Here you see 5 articles are displayed.


Scenario 2:-

  1. Article content is displayed
  2. There are more paragraphs are displayed in an article. In centre of the page , mobile ad(Image) will be displayed.
  3. Mobile Ad(Image) will be displayed only when we scroll to position of centre of an article. I want to verify that image is present or not.
  4. This is a article page, When you scroll, Mobile Ad(image) will be displayed

How can i do it above scenarios?

@amitjaincoer191
I have tried the following Scenario1 for scroll a page. Scroll happens at once. Then its get stopped

Scenario 1:-
Dimension dimensions = driver.manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.5;
int scrollStart = screenHeightStart.intValue();
System.out.println("s="+scrollStart);
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();
driver.swipe(0,scrollStart,0,scrollEnd,2000);
sleep(10000);

Scenario2:-

I have tried following for scroll. Scroll is happening till end of page and it keep on scrolling for some time and throws error.
Dimension dimensions = driver.manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.5;
int scrollStart = screenHeightStart.intValue();
System.out.println("s="+scrollStart);
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();
for (int i = 0; i < dimensions.getHeight(); i++) {
driver.swipe(0,scrollStart,0,scrollEnd,2000);
}

I need to stop scrolling when it reach of end of page.

What I need to change here to make it work perfectly.

You can only conclude that u reach to end of page if u r test case says to click this element

so put terminating condition like

for (int i = 0; i < dimensions.getHeight(); i++) {
driver.swipe(0,scrollStart,0,scrollEnd,2000);
if (driver.findElement(By.name("YourText")).size()>0)
exit;
}
driver.findElement(By.name("YourText")).click();

so with this for each scroll it will check that element is visible if yes it will come out of loop and click it else it keeps on scrolling.

@amitjaincoer191 Consider I have reached end of page. I am trying to do scrolling, control won't beyond page as it is reached end of page.

I am trying to do driver.swipe method in end of page. How can i say I can able to do swipe or not ?

consider last visible element and remember it. not changed = we reached end.

2 months later

@amitjaincoer191, can you explain why you're using startx+20 and moving to endx+20? If i'm not wrong, the +20 indicates the pixels. So, when you're moving from point A to point B, the coordinates should be (x,y) to (x+20,y+20), is that right?

@lostinhogwarts

It depends how u want to move

(0,0) (0,10) - move 10 units in y direction vertical up swipe (0,10) - move 10 units in y direction vertical down swipe (10,0) - move 10 units in x direction horizontal right swipe (10,0) - move 10 units in x direction [horizontal left swipe]

+20 or -20 from computed coordinates using getLocation.getX() / getLocation.getY() simply means a kind of error removing way some time computed coordinates are on extreme boundary of screen so swipe goes wrong

2 months later

do not use for loop for (int i = 0; i < dimensions.getHeight(); i++)

2 months later
3 months later

Hi,

scenario 1 works well for me if the element I am looking for exist.
But if it doesn't exist how can I stop the for loop when I reach the end of the page, if I don't know the last element of the page?

More precisely,
I am trying to check if a given element exist in a page. To do that, I use the scenario 1.
It's perfect if the element is found but if it isn't found, the scenario 1 continue to run until the end of "for" loop is reached, even if the end of the page is reached.

I can't know the last element of the page because it's a list that is specific for each App user and that can be change (add / remove element).

Thanks.

Thank you Karunakaran_M.

I already used the workaround with the swipe method and loop a predetermined number of time to find a specific element.

But I wonder, instead to have a predetermined number of time:
for i=0; i <10; i++,
we can have a way something like:
for i=0; i < "end of page"; i++ OR while(! "end of age")
where "end of page" is not fix <=> not necessary the same element at the end of the page.

So far, I swipe screen by screen and retrieve the last element text of the current screen, and compare with the previous last element text (of the previous screen).
If it's the same => I reach the end of the page and stop the loop.

But I am not sure it's the best way to do that :wink:

Have a nice day

5 months later

Hi Guys,

driver.scroll();
driver.scrollTo();

not coming when i'm doing driver.

2 months later

Even for me scenario 1 worked fine....

I am scrolling an overlay not a page !!! Super !

20 days later

Hi Karunakaran, Could you pease share the code to retrieve the last element in the page?

Cheers,
Dev

7 months later

When I login into an iOS App, in the next page, I have to click on a “Next” button in the bottom of that page .
For that I have to scroll down.
I have been trying to use the below code, but it isn’t working for me:

                    Dimension dimensions = driver.manage().window().getSize();
	    Double screenHeightStart = dimensions.getHeight() * 0.5;
	    int scrollStart = screenHeightStart.intValue();
	    System.out.println("s="+scrollStart);
	    Double screenHeightEnd = dimensions.getHeight() * 0.1;
	    int scrollEnd = screenHeightEnd.intValue();
	    for (int i = 0; i < dimensions.getHeight(); i++)
                    {
	    driver.swipe(0,scrollStart,0,scrollEnd,2000);
	    if (driver.findElement(By.id("Next")).isDisplayed()) 
	    	break;
                     }

Please help me with how to tackle this problem. It is scrolling upwards instead of down

26 days later
27 days later