Closed oz123 closed 7 years ago
Just reading through your bug report: In your HTML it is del_1
yet in your Pdb++ example it is del1
... is that an expected inconsistency?
Just a note that webtest's clickbutton
API states the following:
Like click(), except looks for link-like buttons. This kind of button should look like
<button onclick="...location.href='url'...">
.
It doesn't look like clickbutton
is for submitting forms or other actions.
@bertjwregeer as for the inconsistency, that is not the problem. I fixed the code. In the beginning, I tried with _
and also without it. That is why the inconsistency (I copied examples from two different terminal).
As for onclick="...location.href='url'...
The documentation here is not clear to me. I have hardly seen examples in HTML that use that syntax. Can you maybe post a concrete example?
In the mean while, I am doing the following to click that button:
res = res.goto("/delete/", params={"serial": "abcdef123",
res.html.form.input['name']:
res.html.form.input['value']})
@oz123 clickbutton
works on code that looks like this:
<button onclick="window.location.href='http://google.com/';">Go to Google</button>
It's similar to click
which follows this:
<a href="http://google.com/">Go to Google</a>
Except happens to use a button
tag and thus uses onclick
.
You should use .submit('name_of_the_button')
But webtest do not support html5 forms (it is (was?) really hard https://github.com/Pylons/webtest/issues/8) so your formaction will be ignored
@gawel if formaction
is ignored it will submit the whole form I am afraid, and I would not want that.
I think, app.get
is my only solution here.
As much as I appreciate WebTest, I think it is time for me to look for a more comprehensive solution (I am hitting the limits of what I can do with webtest too many times ...).
@oz123 You would be more looking at doing testing using Selenium with a testing framework against a real browser...
There are a bunch of libraries out there to accomplish what you want which will allow much more thorough testing of site behaviour, especially once you also start adding JavaScript.
@bertjwregeer, yes. I really hated selenium back than when I used it, so I settled for WebTest for it's simplicity and elegance. Lately, I bumped into https://github.com/cobrateam/splinter, which seems to make selenium nicer to use. In my next application I will look into it.
This have been discussed before, and I really wish this would be possible.
I have a form which looks like this:
I can't click this button ... but it is found with BeatifulSoup:
Is there any possible work around this?