1

I am trying to write a selenium test for the submission of a form, which uses intercooler.js when it is submitted. The main problem I am having, is that when I navigate to the page, the form has class="disabled", which is not expected behaviour, and I can't submit the form. The relevant part from the intercooler docs says:

By default, intercooler will apply the disabled class to the element that triggers an intercooler request. This can be used to give a visual hint to the user that they should not click or otherwise trigger the request again, and is Bootstrap-friendly.

However, it seems to me that the disabled class is being added to the form element before I actually submit the form, and as I understand it should only be added after a request is in-flight.

The form currently looks like this:

<form ic-post-to="/dashboard/calculate/2/exports/" ic-select-from-response="#content" ic-target="#content" method="post" ic-src="/dashboard/calculate/2/exports/" ic-verb="POST" ic-trigger-on="default" ic-deps="ignore" class="disabled">
    <input type="hidden" name="csrfmiddlewaretoken" value="...">
    <input type="submit" name="new" value="New" class="btn btn-primary float-right ml-1" id="submit-id-new">
</form>

I have tried adding explicit and implicit waits so that the entire page will load but the problem is still there.

Any help with this would be much appreciated.

2 Answers 2

2

Try to use Javascript to click on the button:

submit = driver.find_element_by_id("submit-id-new")
driver.execute_script("arguments[0].click();", submit)
2
  • I have tried this before and it didn't work, it should redirect to a new page but it remains on the same page
    – BeeNag
    Jul 19, 2018 at 9:47
  • 1
    Yeah I've actually solved this. It turns out the problem was that I needed to wait after the submit button was pressed, not on page load, as when the form is submitted it only causes a partial update of the page content
    – BeeNag
    Jul 19, 2018 at 9:54
1

It turns out that I was waiting in the wrong place. Instead of waiting when the page loads, I should have been waiting after the form was submitted to allow the page content to be updated.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.