KWC
KWC

Reputation: 71

Unable to click dropdown from combo box

Using : Cucumber Watir / Web Driver

I am trying to click the drop-down element or any element that will open the list.

My error is:

undefined method `click' for # (NoMethodError)

My Watir code is:

@browser.divs(:class => 'dd-field').click  #I have tried other Class names from the html. Can’t get it to click

My HTML ( That is highlighted per firebug ):

<div class="header">Deposit•to</div>
<div class="dropdown" ng-class="secondaryClass()">
<div class="dd-field" on="!selectedAccount" ng-switch="">
-- ngSwitchWhen: false -->
<!-- ngSwitchDefault: -->
<div class="dd-label ng-scope" ng-switch-default="">Select•an•account</div>
<div class="dd-arrow-box">
<div class="dd-arrow"></div>
</div>

I tried Fire on event click without success.

Upvotes: 0

Views: 129

Answers (1)

Yi Zeng
Yi Zeng

Reputation: 32855

You get that error because you are using @browser.divs instead of @browser.div, notice one is plural divs, which returns a list of <div> elements, so no wonder you can't click a list of elements.

Try use @browser.div instead, which returns one single element and you should be able to click.

@browser.div(:class => 'dd-field').click

Upvotes: 1

Related Questions