michele mendel
2006-Oct-11 08:09 UTC
[Mechanize-users] Mechanize: save and cancel doesn''t work in JSPWiki
I''m trying to submit data in JSPWiki (edit page). I can read the data in the form, but nothings get saved when I submit the page. Cancel doesn''t work either. I don''t get any errors. There is no JavaScript used to submit the form. After I''m logged in I do the following: def save(page, content) @agent.get(@base_url + "Edit.jsp?page=#{page}") form = @agent.page.forms.with.name(''editForm'') form.fields.name(''_editedtext'').value = content form.submit(form.buttons.first) end And this is the cancel method (the @agent already got the edit page) def cancel form = @agent.page.forms.with.name(''editForm'') form.submit(form.buttons.name(''cancel'')) end Michele NOTE: I''m guessing that the problem could be that some header data is wrong or missing, which causes JSPWiki not to handle the request. logfile INFO mech: Net::HTTP::Get: http://[A URL]:880/coswiki/Login.jsp DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:33 GMT DEBUG mech: response-header: content-type => text/html;charset=UTF-8 DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 7968 DEBUG mech: response-header: set-cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F; Path=/coswiki DEBUG mech: saved cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F INFO mech: status: 200 DEBUG mech: query: "j_username=red&j_password=red&page=Login&action=login" INFO mech: Net::HTTP::Post: http://[A URL]:880/coswiki/Login.jsp DEBUG mech: using cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: request-header: content-type => application/x-www-form-urlencoded DEBUG mech: request-header: cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: referer => http://[A URL]:880/coswiki/Login.jsp DEBUG mech: request-header: content-length => 53 DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:33 GMT DEBUG mech: response-header: content-type => text/html DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 0 DEBUG mech: response-header: set-cookie => JSPWikiAssertedName=Red; Expires=Wed, 08-Jul-2009 08:01:34 GMT DEBUG mech: response-header: location => http://[A URL]:880/coswiki/Wiki.jsp DEBUG mech: saved cookie: JSPWikiAssertedName=Red INFO mech: status: 302 INFO mech: follow redirect to: http://[A URL]:880/coswiki/Wiki.jsp INFO mech: Net::HTTP::Get: http://[A URL]:880/coswiki/Wiki.jsp DEBUG mech: using cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: request-header: cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: referer => http://[A URL]:880/coswiki/Login.jsp DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:33 GMT DEBUG mech: response-header: content-type => text/html;charset=UTF-8 DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 15873 INFO mech: status: 200 INFO mech: Net::HTTP::Get: http://[A URL]:880/coswiki/Edit.jsp?page=OldWikiNewWikiDiff DEBUG mech: using cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: request-header: cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: referer => http://[A URL]:880/coswiki/Wiki.jsp DEBUG mech: response-header: last-modified => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: cache-control => max-age=0 DEBUG mech: response-header: expires => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:33 GMT DEBUG mech: response-header: content-type => text/html;charset=UTF-8 DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 16598 INFO mech: status: 200 DEBUG mech: query: "page=OldWikiNewWikiDiff&action=save&edittime=1160553663011&_editedtext=Hello+Knucklehead" INFO mech: Net::HTTP::Post: http://[A URL]:880/coswiki/Edit.jsp?page=OldWikiNewWikiDiff DEBUG mech: using cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: request-header: content-type => application/x-www-form-urlencoded DEBUG mech: request-header: cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: referer => http://[A URL]:880/coswiki/Edit.jsp?page=OldWikiNewWikiDiff DEBUG mech: request-header: content-length => 88 DEBUG mech: response-header: last-modified => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: cache-control => max-age=0 DEBUG mech: response-header: expires => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: content-type => text/html;charset=UTF-8 DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 16579 INFO mech: status: 200 INFO mech: Net::HTTP::Get: http://[A URL]:880/coswiki/Logout.jsp DEBUG mech: using cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: request-header: cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: referer => http://[A URL]:880/coswiki/Edit.jsp?page=OldWikiNewWikiDiff DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: content-type => text/html DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 0 DEBUG mech: response-header: set-cookie => JSPWikiAssertedName=; Expires=Thu, 01-Jan-1970 00:00:10 GMT DEBUG mech: response-header: location => http://[A URL]:880/coswiki/. DEBUG mech: saved cookie: JSPWikiAssertedName INFO mech: status: 302 INFO mech: follow redirect to: http://[A URL]:880/coswiki/. INFO mech: Net::HTTP::Get: http://[A URL]:880/coswiki/. DEBUG mech: using cookie: JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: accept => */* DEBUG mech: request-header: accept-encoding => gzip,identity DEBUG mech: request-header: user-agent => Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 DEBUG mech: request-header: cookie => JSESSIONID=C08FB593CBE5508710F02C4AFAEEA09F DEBUG mech: request-header: referer => http://[A URL]:880/coswiki/Logout.jsp DEBUG mech: response-header: date => Wed, 11 Oct 2006 08:01:34 GMT DEBUG mech: response-header: content-type => text/html;charset=UTF-8 DEBUG mech: response-header: server => Apache-Coyote/1.1 DEBUG mech: response-header: content-length => 14751 DEBUG mech: response-header: set-cookie => JSESSIONID=9DA2FF21FBD3AB05AE657E5D582FE8D5; Path=/coswiki DEBUG mech: saved cookie: JSESSIONID=9DA2FF21FBD3AB05AE657E5D582FE8D5 INFO mech: status: 200 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mechanize-users/attachments/20061011/b86246cd/attachment.html
Aaron Patterson
2006-Oct-11 20:00 UTC
[Mechanize-users] Mechanize: save and cancel doesn''t work in JSPWiki
Hi Michele, On Wed, Oct 11, 2006 at 10:09:57AM +0200, michele mendel wrote:> I''m trying to submit data in JSPWiki (edit page). I can read the data > in the form, but nothings get saved when I submit the page. Cancel > doesn''t work either. I don''t get any errors. There is no JavaScript > used to submit the form. >This might be a dumb question, but how do you know that cancel doesn''t work? What are you expecting it to do?> After I''m logged in I do the following: > > def save(page, content) > @agent.get(@base_url + "Edit.jsp?page=#{page}") > form = @agent.page.forms.with.name(''editForm'') > form.fields.name(''_editedtext'').value = content > form.submit(form.buttons.first) > end > > And this is the cancel method (the @agent already got the edit page) > > def cancel > form = @agent.page.forms.with.name(''editForm'') > form.submit(form.buttons.name(''cancel'')) > end > Michele[snip] It is hard for me to debug this from just the headers... I''d actually have to try it out. So I used the wiki set up on jspwiki.org with the following script: agent = WWW::Mechanize.new page = agent.get(''http://www.jspwiki.org/Edit.jsp?page=TestPage'') form = page.form(''editForm'') { |f| f._editedtext << "baz" } agent.submit(form, form.buttons.first) And that seems to work fine for me. Is there a place that is publicly available where you can reproduce this error? -- Aaron Patterson http://tenderlovemaking.com/
michele mendel
2006-Oct-11 20:35 UTC
[Mechanize-users] Mechanize: save and cancel doesn''t work in JSPWiki
On 10/11/06, Aaron Patterson <aaron_patterson at speakeasy.net> wrote:> > Hi Michele, > > On Wed, Oct 11, 2006 at 10:09:57AM +0200, michele mendel wrote: > > I''m trying to submit data in JSPWiki (edit page). I can read the data > > in the form, but nothings get saved when I submit the page. Cancel > > doesn''t work either. I don''t get any errors. There is no JavaScript > > used to submit the form. > > > > This might be a dumb question, but how do you know that cancel doesn''t > work? What are you expecting it to do?[michele] When you start to edit a page that someone else has started to edit, you''ll get informed about this. My script logs in, starts to edit the page and then saves or cancels. When I want to edit the same page I get the information that ''red'' is still working on it, i.e. cancel didn''t work.> After I''m logged in I do the following: > > > > def save(page, content) > > @agent.get(@base_url + "Edit.jsp?page=#{page}") > > form = @agent.page.forms.with.name(''editForm'') > > form.fields.name(''_editedtext'').value = content > > form.submit(form.buttons.first) > > end > > > > And this is the cancel method (the @agent already got the edit page) > > > > def cancel > > form = @agent.page.forms.with.name(''editForm'') > > form.submit(form.buttons.name(''cancel'')) > > end > > Michele > [snip] > > It is hard for me to debug this from just the headers... I''d actually > have to try it out. So I used the wiki set up on jspwiki.org with the > following script: > > agent = WWW::Mechanize.new > page = agent.get(''http://www.jspwiki.org/Edit.jsp?page=TestPage'') > form = page.form(''editForm'') { |f| > f._editedtext << "baz" > } > > agent.submit(form, form.buttons.first) > > And that seems to work fine for me. Is there a place that is publicly > available where you can reproduce this error?[michele] I''ll check that out. I will also try to use your code, because I got errors with agent.submit. That''s why I use form.submit. --> Aaron Patterson > http://tenderlovemaking.com/ > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mechanize-users/attachments/20061011/ec973d9a/attachment.html