danh / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Unable to scroll the WebView with in-built Robotium-Solo scroll methods and unable to locate the element without scrolling . #529

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Renas,

I'm testing a hybrid app and have come across two hurdles.

1. I'm unable scroll a webview using the in-built robotium-solo's scroll 
methods. Though i can scroll the screen by using solo.sendKeys() method but i 
do not find it to be much effective.

2.I want to locate a particular element for which scrolling down is required , 
when i try to locate the element on a WebView using  
solo.getWebElement(By.xpath("XPATH_OF_THE_ELEMENT"));,
the above mentioned method does not locate the element by scrolling on its own. 
Infact it throws an error saying element not found as it wasn't visible to it 
on the current display.

So please provide your valuable inputs on the same.

Thanks,
Zaid 

Original issue reported on code.google.com by Zaid.I.M...@gmail.com on 6 Oct 2013 at 12:21

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Would it be possible for you to share an app that 
exhibits this issue?

Original comment by renasr...@gmail.com on 7 Oct 2013 at 10:13

GoogleCodeExporter commented 9 years ago
I wish I could really do that. But Sorry to say i cannot really share the app. 

But then, how can we get this issue resolved and by when.?

Original comment by Zaid.I.M...@gmail.com on 7 Oct 2013 at 4:13

GoogleCodeExporter commented 9 years ago
Unfortunately we can not do anything about it if we cant reproduce it. Will 
keep this issue open, hopefully someone can provide us an app that exhibits 
this issue. 

Original comment by renasr...@gmail.com on 8 Oct 2013 at 7:18

GoogleCodeExporter commented 9 years ago
Hi, I had that same issue for an xpath beginning with /html/body/tr/td/button 
which was not identified by 
solo.waitForWebElement(By.xpath("/html/body/tr/td/button"))

But I succeed to identify an Xpath which a modify by .//[contain(@class,'name 
of class')]/tr/td/button

I think /html/body/... is not correctly identified.

Original comment by minuip...@gmail.com on 8 Oct 2013 at 10:09

GoogleCodeExporter commented 9 years ago
Hi  minuip,

Thanks but the issue is related to more of scrolling, the section of the page 
loaded in the next half of the device screen .

Original comment by Zaid.I.M...@gmail.com on 11 Oct 2013 at 5:09

GoogleCodeExporter commented 9 years ago
I have come across a similar issue when testing the Fresh Food Finder app 
(https://github.com/triceam/Fresh-Food-Finder). More specifically, when a DOM 
element is out of view, waitForWebElement does not scroll down as expected 
(regardless of what By object is passed). The workaround I ended up using was 
as follows: I extended Robotium's Waiter class and implemented a new method 
called waitForWebElementByDragging(). This new method performs a drag (with the 
help of the drag() method in Scroller.java) instead of a scroll. Works pretty 
well, I'd say.

Generally speaking though, I think it would be useful to modify 
waitForWebElement such that it performs not only scrolldowns, but also 
scrollups (e.g., Let's say you want to click element A, then B. What if you've 
just scrolled down to execute a click on DOM element A, but this brings B out 
of view and you have to scroll back up to click on B? You can do a scrollup 
manually I suppose, but this isn't exactly very elegant because it assumes you 
know precisely how the elements are positioned). This is a totally separate 
issue, however.

Original comment by focariz...@gmail.com on 6 Nov 2013 at 7:33

GoogleCodeExporter commented 9 years ago
Hi Focariz,

Thanks for the information.

But i had tried using drag() even that wasn't fruitful.

Well if you don't mind can you please share the code for 
waitForWebElementByDragging().

Thanks,
Zaid

Original comment by Zaid.I.M...@gmail.com on 7 Nov 2013 at 5:52

GoogleCodeExporter commented 9 years ago
@focarizajr, thanks for the app suggestion. 

Original comment by renasr...@gmail.com on 7 Nov 2013 at 6:26

GoogleCodeExporter commented 9 years ago
The only way we've found to fix this is by doing the click directly from 
Javascript. Please use Robotium 5.0.1. In the new Config class, set:

conf.useJavaScriptToClickWebElements = true

See the javadoc on how to use the Config class. 

Original comment by renasr...@gmail.com on 6 Jan 2014 at 7:57