gpt4 book ai didi

tinymce - cucumber 测试给出错误 - Selenium::WebDriver::Error::JavascriptError

转载 作者:行者123 更新时间:2023-12-04 10:47:46 25 4
gpt4 key购买 nike

我的页面中有一个 tinymca 的 iframe,我想用 cucumber 测试填充那个 tinymca 编辑器。每当我运行测试时,它都会给我错误,即未定义 jQuery

在我的 Gemfile 中

source 'http://rubygems.org'
ruby '2.0.0'

gem 'capybara'
gem 'capybara-mechanize', :git => 'git://github.com/JerryWho/capybara-mechanize.git', :branch => 'relative-redirects'
gem 'rspec'
gem 'cucumber'
gem 'launchy'
gem 'pry'
gem 'selenium-webdriver'

这是我的场景
Scenario: admin puts all the valid and require data  
when Job added with all the valid and require data
Then I should see the success message.

这是该测试的步骤
Given(/^I am logged in as a company admin$/) do
visit('/')
fill_in "log", :with => "admin@email.com"
fill_in "pwd", :with => "password"
click_button "submit"
end

When(/^Job added with all the valid and require data$/) do
visit('/site/admin/posts/add/')
within_frame 'questiontextarea_ifr' do
page.execute_script("jQuery(tinymce.editors[0].setContent('my content hersssssssssse'))")
end
click_button "Save"
end

Then(/^I should see the success message\.$/) do
page.should have_content('Success Your post has been successfully added.')
end

但它给了我错误 jQuery is not defined (Selenium::WebDriver::Error::JavascriptError)

最佳答案

正如消息所建议的那样,这很可能是因为“未定义 jQuery”。

请尝试在没有 jQuery 的情况下调用,但使用 native TinyMCE API :

page.execute_script("tinyMCE.activeEditor.setContent('my content hersssssssssse')")

进一步阅读: Test WYSIWYG editors using Selenium WebDriver纯 ruby (不是 capybara )

关于tinymce - cucumber 测试给出错误 - Selenium::WebDriver::Error::JavascriptError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24032154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com