David Geismar
David Geismar

Reputation: 3422

Change option in select using Ruby Mechanize

I am using Mechanize gem.

I am trying to select and submit an option on a web page :

<select class="transform" onchange="if(this.value != '')document.location.href=this.value;">

This select is not part of a form. It is just a select that triggers a javascript action onchange. How can I set the select to the option I want and trigger the js onchange ?

Upvotes: 0

Views: 243

Answers (1)

pguardiario
pguardiario

Reputation: 54984

Let's say the option looks like this:

option = page.at('option[text()=foo]')

You would do the action (change location to the option's value) with:

page = agent.get option[:value]

Upvotes: 1

Related Questions