[英]I get an error while running an JS script with capybara/selenium/ruby
我是自动化的新手,我使用Selenium,ruby,capybara来执行这个JS脚本,我收到此错误消息,任何帮助赞赏TIA错误消息Selenium :: WebDriver :: Error :: UnknownError:unknown error:Runtime.evaluate thrrew exception:SyntaxError:无效或意外的令牌
page.execute_script('(function(){
function renderField($el, mode) {
var limitMet,
field = $el.data(\'add-field\'),
section = $el.data(\'section\');
window.DADI.editor.freeSections.forEach(function(freeSection) {
if (section === freeSection.name) {
freeSection.fields.forEach(function(sectionField) {
if(field === sectionField.source) {
var count = $(\'#section-\' + section).find(\'[data-field="\'+field+\'"]\').length;
if (sectionField.max && count >= sectionField.max) {
limitMet = true;
}
}
}.bind(this))
}
}.bind(this))
if (!limitMet) {
if (!window.DADI.editor.types[field]) return false;
var template = window.DADI.editor.types[field]._local.layouts.article[0].replace(\'.dust\', \'\');
var html;
if (template) {
var templateData = window.DADI.editor.types[field];
templateData.params = window.DADI.editor.params,
templateData.free = true;
templateData.fieldName = field;
window.DADI.render.render(\'fields/\' + template, \'#section-\' + section, templateData, {mode: mode}, function (err, out) {
if (err) {
html = err;
} else {
html = $(out);
if ($(\'.selectize\', html) && $(\'.selectize\', html).length) {
dadiSelect($(\'.selectize\', html));
}
if (html.attr(\'data-ql-editable\')) {
createEditor(html, 0);
html.focus();
}
var fieldType = window.DADI.editor.types[field]._remote._publishType;
var handler = window.DADI.editor.handlers[fieldType];
if (handler && (typeof handler.initialiseField === \'function\')) {
handler.initialiseField(html);
}
}
});
return html;
}
}
}
# This takes the button (source) element and drops it into the target area and subsequently renders the appropriate cms fields.
function simulateDragAndDrop(source, target)
{
var $clone = source.clone();
$(target).prepend($clone, target);
if ($clone.hasClass(\'dadiCells-library__element\')) {
renderedHtml = renderField($clone, \'none\');
$clone.replaceWith(renderedHtml);
}
}
var source = $($(\'.dadiCells-library__element\')[1]); #E.g. The hero video button
var target = $(\'#section-hero\'); #The target drop zone.
simulateDragAndDrop(source, target);
})()')
我有一个类似的问题。 我的固定装置正在替换单个后背/
双后座//
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.