williamabradley / mechanize.net Goto Github PK
View Code? Open in Web Editor NEWStateful programmatic web browsing, based on Python-Mechanize, which is based on Andy Lester’s Perl module WWW::Mechanize.
License: MIT License
Stateful programmatic web browsing, based on Python-Mechanize, which is based on Andy Lester’s Perl module WWW::Mechanize.
License: MIT License
I used this little piece of code to get access to an TextInputControl on a form.
using (var browser = new MechanizeBrowser())
{
var page = await browser.NavigateAsync("https://<blabla>");
if (page.IsHtml)
{
var form = page.Forms["login"];
var queryfield = form.FindControl<TextInputControl>("param3");
....
}
}
The login form contains some controls, some w/o having the name attribute set. This results in a NullReferenceException when calling form.FindControl.
I cloned the repro locally and found the issue in HtmlForm.cs.
public T FindControl<T>(string Name) where T : HtmlFormControl
{
return (T)this.FirstOrDefault(item => item.Name != null && item.Name.Equals(Name,StringComparison.OrdinalIgnoreCase));
}
The code on Master lacks a check whether item.Name is set to any string. I added a null check as a bugfix. If I don't miss any side effect you may include this into your master as well.
Best regards,
Marcus
When the html control is the HtmlFormControl.GetControlType method should return FormControlType.Submit
The link you have in the README is tied to me as an author, which I haven't been for years. A better link would be http://search.cpan.org/dist/WWW-Mechanize or https://metacpan.org/pod/WWW::Mechanize
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.