0
votes

I am trying to click on the button.

<input data-ember-action="797" value="Search Now" class="cta-1st clrboth primary search-button firepath-matching-node" type="button">

but it keep showing an error of not finding the element to click. it finds all the elements until the end but when it comes to "click" it throws an error. My code is like this:

 @browser.div(:id=>'ember730').section(:class=>'tab-pane fade active in').form(:class=>'flight-search ').input(:class=>'cta-1st clrboth primary search-button').click

Am I missing something? I am using Watir

2
There are a number places that this could be failing. It would help if you can share a page that reproduces the exception, as well as the exact exception. - Justin Ko
As a random guess, I would try simplifying the approach. Are there really that many search buttons that require being so specific on where to find the button? Do all of those CSS classes actually help be more specific? I'd start off with @browser.button(class: 'search-button').click and then only add more specifics if needed. - Justin Ko
There are 5 buttons which are in the different section have the same class name "search-button". - user1669556
Also, which Watir version? Locating multiple classes with the :class key has been deprecated. With the latest version (6.7.1 was released today), you would want to put the ones you care about into an array ['cta-1st', 'clrboth', 'primary', 'search-button']. Also prefer the #button method over the generic #input method - titusfortner
@user1669556 can you show what put @browser.button(class: 'search-button').length returns? I would be willing to bet it is returning an array and you need to put @browser.button(class: 'search-button').first.click - Tall Paul

2 Answers

0
votes

Thank you for all the help here. the problem was, I had a wrong reading in one of the elements.
I was missing this part.

@browser.div(:id=>'ember730').section(:class=>'tab-pane fade active in').form(:class=>'flight-search ').text_field(:class=>'cta-1st clrboth primary search-button firepath-matching-node').click
0
votes

As there is value="Search Now" section of type="button" here, following simple code snippet should do. I have made this working using Watir in my project..

@browser.button(value: "Search Now").click