nickylin / nativedriver

Automatically exported from code.google.com/p/nativedriver
Apache License 2.0
0 stars 0 forks source link

findElementsByText should not find text that is invisible #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a <TextView> like the following:
        <TextView
                android:id="@+id/textViewId"
                android:text="SOME_TEXT"
                android:visibility="gone">

2. Invoke driver.findElementsByText("SOME_TEXT") or 
driver.findElementsByPartialText("SOME_TEXT")
3. findElements will find and return the above web element.

What is the expected output? What do you see instead?
There should be no matches found as the text is not visible on the screen.

What version of the product are you using? On what operating system?
MacOSX, Android 2.2

Please provide any additional information below.

Would it make sense to add an isShown() to AndroidNativeElement.java?  We'd 
then have:

ViewElement.java
============
@Override
public boolean isShown() {
    return view.isShown();
}

ElementFinder.java
============
In the find methods, utilize input.isShown() to filter out those that are not 
visible.

Thanks.

Original issue reported on code.google.com by davincid...@gmail.com on 25 Jul 2011 at 7:32

GoogleCodeExporter commented 9 years ago
You can use WebElement#isDisplayed() to check if the element is shown or not.
Could you check the visibility in your test code?

WebElement element = driver.findElementByText("SOME_TEXT");
assertFalse(element.isDisplayed());

Original comment by tka...@google.com on 26 Jul 2011 at 1:41

GoogleCodeExporter commented 9 years ago
Thanks for the suggestion.

However, it seems that isDisplayed is not on the org.openqa.selenium.WebElement 
interface.

Original comment by davincid...@gmail.com on 26 Jul 2011 at 4:37

GoogleCodeExporter commented 9 years ago
Oh, sorry. It'a bug.

AndroidNativeElement should extend 
org.openqa.selenium.remote.RenderedRemoteWebElement rather than 
RemoteWebElement, and you will be able to use 
AndroidNativeElement#isDisplayed().

Original comment by tka...@google.com on 27 Jul 2011 at 1:41