Your problem is that username and password fields are not inside form.
Open Firebug and inspect those fields and you will see that.
Instead don't vorry where it is, just select field with name fblogincd
and fbpassword,
fill in with data, and click on input element with id sImage1. That's all.

Is your requirement strictly Mechanize? Mechanize is good for simpler sites
without javascript. If you need javascript (you will need it, before or
later) then Capybara is better solution. I could write you simple script in
Capybara to do this task.


2012/11/4 john smith <[email protected]>

> new to ruby, love the language. read programmatic programmers guide to
> get started and i understand the basics of ruby language. im just
> starting to learn gems, ive played with mysql, crypt, and now mechanize.
> I have yet to write a successful program with any of the gems but im
> hooked on mechanize. ok so here is what im trying to do...
> i am a student in itt tech online course. to get credit for attendance i
> have to send emails everyday through the webpage. so i thought "yesss!!!
> i can write a program using mechanize to do this for me."
> First question: is that even possible?
>
> next i can get to the webpage and can print the forms but dont know how
> to fill it out to submit it. here is my code and what i see when
> executed:
>
> #THIS IS MY CODE
> require 'rubygems'
> require 'mechanize'
>
> agent = Mechanize.new
> page = agent.get('http://www.distance-education.itt-tech.edu/')
>
> form = page.forms.each do |form|
>   pp form
> end
> =================================================================
> #THIS IS WHAT IS PRINTED OUT
> #<Mechanize::Form
>  {name "loginForm"}
>  {method "POST"}
>  {action "javascript:exit('/online/valdoc/cliksIndep_prcsslogin')"}
>  {fields
>   [hidden:0x1a09478 type: hidden name: fbcorporateid value: 2222]
>   [hidden:0x1a093a0 type: hidden name: fbautologin value: 0]
>   [hidden:0x1a092d4 type: hidden name: fbloginhome value: ITT]
>   [hidden:0x1a09208 type: hidden name: fbGrade value: null]
>   [hidden:0x1a0913c type: hidden name: afbTestID value: null]
>   [hidden:0x1a09070 type: hidden name: fbPrgLnchId value: null]
>   [hidden:0x1a08fa4 type: hidden name: fbuid value: null]}
>  {radiobuttons}
>  {checkboxes}
>  {file_uploads}
>  {buttons [imagebutton:0x1a08ef0 type: image name: Login value: ]}>
> ======================================================================
> -ok so i see the form, but i dont know which one i would put my user
> name and password into.
> -Also i use firebug to see the names of the text-fields on the actual
> web page and their "names" are not in the list of fields that are
> printed out.
>
> -so my next question is how do i fill out the username and password
> fields and click the submit button to get to the next page? id like to
> figure it out by myself but i have not been having much luck. any help
> is appreciated thank you!
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to