Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mechanize breaks on ASP page

Tags:

ruby

mechanize

require 'mechanize'
agent = Mechanize.new
login = agent.get('http://www.schoolnet.ch/DE/HomeDE.htm')
agent.click login.link_with text: /Login/

And I get Mechanize::UnsupportedSchemeError.

like image 312
Reactormonk Avatar asked Apr 20 '11 11:04

Reactormonk


2 Answers

Mechanize did'nt support javascript but you can add search field to the form assign search term to it and submit the form using mechanize

form = page.forms.first
form.add_field! "Field_name here","BotM$ucUser$ucUser2Col$cmdLogin"
page = form.submit
like image 170
Raza Hussain Avatar answered Oct 03 '22 02:10

Raza Hussain


The link in question runs a javascript function.

<a href="javascript:__doPostBack('BotM$ucUser$ucUser2Col$cmdLogin','')" id="BotM_ucUser_ucUser2Col_cmdLogin">Login</a>

Mechanize doesn't support javascript links. Someone else suggests using Harmony.

Check https://github.com/mynyml/harmony

like image 40
Charles de Bueger Avatar answered Oct 03 '22 02:10

Charles de Bueger