Ruby Mechanize - Issue in parsing bugzilla page

Hi All,

I am setting some search parameters on bugzilla Advanced search page
(screenshot attached).
Bugzilla allows you to set additional search parameters by clicking the
“Add” button which loads the page again and additional fields are added
at the bottom of the page.
Everything is fine until i click the “Add” button using the following:

page=pageAgent.submit(searchForm,searchForm.button_with(:name =>
‘cmd-add0-3-0’))

Then i set the newly added params which were added in page after Add was
clicked. But i get error message - “undefined method `field_with’ for
nil:NilClass”. Actually i am unable to find the form that has these
fields.
Any idea how to resolve this issue? Please see attached image for more
clarification.

Help much appreciated.

Thanks

It sounds like the ‘Add’ button is triggering an ajax call, which
dynamically loads the new content. Mechanize cannot handle javascript,
maybe look into watir.

David W. wrote in post #1104007:

It sounds like the ‘Add’ button is triggering an ajax call, which
dynamically loads the new content. Mechanize cannot handle javascript,
maybe look into watir.

Hi David,

Thanks for your response. I came across a post where following is
written:

“Try to find out what happens in your browser when you click that link.
Does it create a POST or GET request? What are the parameters that are
sent to the server. Once you know that, you can emulate the same action
in your Mechanize script. Chrome dev tools / Firebug will help out.”

Using Firebug, i have found the following in my case when Add is
clicked:

Any idea if i am able to emulate the same above action using mechanize.
The problem is that i had written all code with mechanize. Now to change
for watir will be lot of effort. Not sure if i can use pass the
mechanize page and form objects to watir and continue with watir where
mechanize is not able to work.

Please let me know.

regards.