Access DOM from capybara-webkit #execute_script?

丶灬走出姿态 提交于 2019-12-13 19:33:21

问题


So I'm trying to test that the jQueryUI sortable library triggers an ajax request and I haven't been successful at triggering it, I've tried this with the jquery.simulate.drag-sortable.js library, but to no avail. I've also tried it with the execute script function, also to no avail. I am trying to manually trigger the sortable deactivate event because jQuery.trigger() doesn't seem to work with it even in the browser. The script that is executed is $sortable.sortable("option", "deactivate")(event, ui) with event and ui properly injected, this code works when I enter it directly into the browser.

The problem seems to stem from not being able to access the DOM. When I enable the debug mode on the driver the error is TypeError: '[object Object]' is not a function (evaluating '$sortable.sortable("option", "deactivate")(event, ui)'). Digging a little deeper reveals that the Javascript driver can't access DOM nodes within #execute_javascript. When I enter console.log(document.getElementById('sortable')); The response is 'null'.

Any thoughts on how to trigger the jQueryUI sortable function with the deactivate event using capybara-webkit?

来源:https://stackoverflow.com/questions/33618611/access-dom-from-capybara-webkit-execute-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!