1

I have an html button:

<button align="center" id="btnApply" width = "100" type="button" value="Apply" style="width:100px" onClick='Submit(1,getElement("btnApply"));'>

I tried to click this button with this code

br.submit(label='Apply',id='btnApply')

but I got this error:

no control matching kind 'clickable', id 'btnApply', label 'Apply'

1 Answer 1

1

Since that button has a JavaScript event attached, mechanize cannot really help you here. It is mostly a HTML parser with some additional support for links and filling out forms. But it cannot interpret JavaScript and generally doesn’t really run anything on that website.

If you’re looking for something that can completely emulate the browser’s behavior on a website with JavaScript support, you should look into a headless browser. This is basically a browser without the “visual” part. For example, you could use PhantomJS and run your tests using Selenium.

Otherwise, if you’re not looking into testing, but just want that one request to go through, you should investigate that website closely and figure out what the Submit(1,getElement("btnApply")) code does. Then emulate that and send the request directly to the server—you don’t even need mechanize then but can likely just do normal HTTP requests (for example using urllib in the standard library or requests).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.