Is it possible to do List<WebElementFacade>

3,914 views
Skip to first unread message

Ilyas Patel

unread,
Feb 19, 2014, 2:09:53 PM2/19/14
to thucydid...@googlegroups.com
Is it possible to have a list of WebElementFacades? I think Thucydides currently supports a single Element.

@FindBy(css = "#savedSearchesContainer #sectionContainer ul li")
private List<WebElementFacade> jobAlertList;

Thanks

Artsiom Zhurbila

unread,
Feb 20, 2014, 7:30:14 AM2/20/14
to thucydid...@googlegroups.com
I have tried using following annotation and it's working properly only with visible elements. E.g. if one of you element has style "style="display: none" you will get exception "org.openqa.selenium.NoSuchElementException: Element is not usable" after "implicitlywait" timeout

@FindBy(css = ".navbar .container div")
public List<WebElementFacade> items;

As workaround you can use the findAll("selector") method inside the page object class

example:
List<WebElementFacade> elements =homePage.findAll("ul li");

        for(WebElementFacade w : elements){
            System.out.println(w.isCurrentlyVisible());
        }

or relative to another WebElementFacade (which is visible):

@FindBy(css = "#sectionContainer")
private WebElementFacade container;

and use thenFindAll():

 List<WebElementFacade> elements = container.thenFindAll("ul li");
        for(WebElementFacade w : elements){
            System.out.println(w.isCurrentlyVisible());
        }



 

John Smart

unread,
Feb 20, 2014, 5:26:12 PM2/20/14
to Artsiom Zhurbila, thucydid...@googlegroups.com
Do you get the "Element is not usable" with a normal List<WebElement> field? I remember getting that sort of thing with normal WebElement lists, so it might be a WebDriver thing. Otherwise, it might be something that can be fixed in Thucydides.


--
You received this message because you are subscribed to the Google Groups "Thucydides Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send an email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
___________________________________________________
John Smart | Wakaleo Consulting  |  +61 407 247 642
Optimizing your software development process
http://www.wakaleo.com  |  john....@wakaleo.com
___________________________________________________

The dates for the 2014 BDD workshops have been scheduled! Check out our upcoming BDD/TDD Master classes and our Advanced BDD Requirements Workshops, coming soon to Sydney and Melbourne!
___________________________________________________

Ilyas Patel

unread,
Feb 28, 2014, 12:47:50 PM2/28/14
to thucydid...@googlegroups.com
This is the error I get:

net.thucydides.core.webdriver.WebdriverAssertionError: java.lang.ClassCastException:

org.openqa.selenium.remote.RemoteWebElement cannot be cast to net.thucydides.core.pages.WebElementFacade


My code like this:

import net.thucydides.core.annotations.findby.FindBy;

@FindBy(css = ".job-overview article section.description p")
private List<WebElementFacade> jobSummaryAndDescription;

I'm running this on my local machine using FireFox and all elements are visible.


Theo

unread,
Nov 5, 2014, 9:15:31 AM11/5/14
to thucydid...@googlegroups.com
Is there any resolution on this topic?

We cannot use

@FindBy(css = ".my-class")
protected List<WebElementFacade> myListOfElements

If I now want to use any WebElementFacade from the list, I get the below class cast exception.

public void doSomething () {
  System.out.println(myListOfElements.get(0)); --> throws exception
}

However, if I define the list inside the method it is used, works fine, i.e.

public void doSomething () {
  List<WebElementFacade> myListOfElements = findAll(By.cssSelector(".my-class"));
  System.out.println(myListOfElements.get(0)); --> works fine
Message has been deleted

Christophe Boschmans

unread,
Nov 17, 2014, 5:33:26 AM11/17/14
to thucydid...@googlegroups.com
I'm having the same issue :@FindBy with a lIst of WebElementFacades gives a classcast exception when using any WebElementFacade from List 

Op woensdag 5 november 2014 15:15:31 UTC+1 schreef Theo:
Reply all
Reply to author
Forward
0 new messages