Open jjlee opened 14 years ago
This should result in the first button being clicked:
import mechanize browser = mechanize.Browser() browser.set_response(mechanize.make_response( """\ <button type="submit" name="action" value="publish">Publish</button> <button type="submit" name="action" value="preview">Preview</button> """, [("Content-Type", "text/html")], "http://example.com/", 200, "OK")) form = browser.global_form() form.click(predicate=lambda control: control.name == "publish")
This should result in the first button being clicked: