我正在尝试编写一个用于提交表单的 Selenium 测试,它使用 intercooler.js当它被提交时。我遇到的主要问题是,当我导航到该页面时,表单具有 class="disabled"
,这不是预期的行为,并且我无法提交表单。 intercooler
文档中的相关部分说:
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.
但是,在我看来,禁用的类是在我实际提交表单之前添加到表单元素中的,据我所知,它应该只在请求正在进行后添加。
当前的表单如下所示:
<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>
我尝试添加显式
和隐式
等待,以便加载整个页面,但问题仍然存在。
任何有关此问题的帮助将不胜感激。
最佳答案
尝试使用Javascript
点击按钮:
submit = driver.find_element_by_id("submit-id-new")
driver.execute_script("arguments[0].click();", submit)
关于python - 提交在 Django StaticLiveServerTestCase 中使用 Intercooler 的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51419221/