Issue with dropdown

21 views
Skip to first unread message

Calum Robertson

unread,
May 10, 2014, 10:05:40 AM5/10/14
to fluent...@googlegroups.com
Hi,

I'm using FluentLenium to test my Play web app but I've ran into difficulty when testing a click on a Bootstrap 3 dropdown. The relevant snippet from my view code is:

<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">App Name</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">@Messages.get("project.projects") <b class="caret"></b></a>
<ul class="dropdown-menu">

@projects.map { project =>
<li class="project-menu-item" project-id="@project.id"><a href="#">@project.name</a></li>
}
<li class="divider"></li>
<li id="create-project-menu-item"><a href="#">@Messages.get("project.createproject")</a></li>
</ul>
</li>
</ul>

When I press the button with class .navbar-toggle, I can see in the Elements tab of Chrome that the <li> element with class "dropdown" changes to "dropdown open". In my test code, after I execute a FluentWebElement click() on the button, the class of the <li> element never changes to "dropdown open". My code for clicking the button is:

   public void clickProjectsDropdown()
    {
        FluentWebElement dropdown = element.findFirst("button[class=navbar-toggle]");
        dropdown.click();
    }

In my test case I have put in await calls after calling the clickProjectsDropdown method and then tested using:

assertThat(browser.pageSource()).contains("dropdown open");

but the assert fails.


Has anyone experienced a similar issue?
Reply all
Reply to author
Forward
0 new messages