I am getting Ruby Error: syntax error, unexpected tGVAR, expecting $end.
I am using Mechanize to access a website and then I need to enter data into the form to search. When I pp page the site to get the form information I get:
#<Mechanize::Form
<name nil>
<method "POST">
<action "">
<fields
...
...
[text:0xb43f9c type: text name: ct100$MainContent$txtNumber value: ]
...
My code that is throwing this is:
Check_form = page.form()
Check_form.ct100$MainContent$txtNumber = 'J520518'
Any ideas on what is causing the error? Thank you in advance for the help!
Since this is not a valid variable or syntactically valid method name, you should use the alternate method to fetch or assign the values:
Variables are of the form
@xfor class instance variables,@@xfor class variables,$xfor global variables andxfor plain variables, but in all cases the variable must consist of a letter or underscore followed by any number of letters, numbers, or underscores.$cannot appear anywhere but the beginning, and when it does that means “global variable”, something rarely used in most Ruby programming.