获取冻结错误 - 无法修改冻结字符串



运行下面提到的cod时出现冻结错误。还可以找到助手文件。以下是主文件:

需要"spec_helper.rb"需要"rspec_capibara\ssignment_helper.rb">

describe 'Open the automationpractices site' , :type => :request do
it 'Test: Page Content', :page do
visit "http://automationpractice.com/index.php"
expect(page).to have_xpath(".//img[contains(@src,'automationpractice.com/img/logo')]")
expect(page).to have_xpath(".//input[@id='search_query_top']")
expect(page).to have_link("Contact us")
expect(page).to have_link("Sign in")
within('div#block_top_menu') do
expect(page).to have_link("Women")
expect(page).to have_link("Dresses")
expect(page).to have_link("T-shirts")
end
within('div#center_column') do
expect(page).to have_link("Popular")
expect(page).to have_link("Best Sellers")
end
expect(page).to have_content("Automation Practice Website")
end 
end

Spec_Helper文件:-Spec_Helper.rb

require 'rspec'
require 'capybara/rspec'
require 'capybara/dsl'
require "selenium-webdriver"
require "capybara"
require 'capybara/rspec/matchers'
RSpec.configure do |config|
config.include Capybara::DSL , :type => :request # to include capybara DSL methods 
config.include Capybara::RSpecMatchers,:type => :request # to include Rspec matchers available.
end
Capybara.configure do |config|
config.run_server = false
config.default_driver = :selenium # which driver to use (selenium / chrome /internet explorer)
config.default_selector = :css #(by default css selector) # if user want to use xpath, he has to write find(:xpath, <xpath>).click
config.app_host = "http://automationpractice.com/index.php" # host app
config.default_max_wait_time = 5 # wait for 4 seconds.
config.app_host = @url
config.ignore_hidden_elements = true # will ignore hidden elements on page.
config.match =:prefer_exact # check for exact match.
end

Rspec水豚任务帮助程序文件:

rspec_capybara_assignment_helper.rbdef click_on(值(find(value(。单击结束

def link_click(value) 
click_link(value)
end
def button_click(value) 
click_button(value)
end
def login_application 
link_click('Sign in')
fill_in('email', :with => 'test.test@testing.com')
fill_in('passwd', :with => 'testtest')
button_click('SubmitLogin')
end
def sign_out 
link_click('Sign out')
end
def search_product(value) 
fill_in('search_query_top', :with => value)
button_click('Search')
sleep(2)
end
def add_product(value) 
page.find(:css,'.product-image-container').hover
sleep(2)
first("a", :text => "More").click
sleep(4)
fill_in('quantity_wanted', :with => '2', visible: false)
select('M', :from => 'group_1')
find('button.exclusive').click
sleep(2)
first("span", :text => "Continue shopping", wait: 3).click
sleep(2)
end
def check_locator(value) 
expect(page).to have_selector(value)
end

错误如下:

打开自动化实践网站测试:页面内容(失败-1(

故障:

  1. 打开自动化实践网站测试:页面内容失败/错误:访问";http://automationpractice.com/index.php">

    Frozen错误:无法修改冻结的字符串

    /spec/tests/rspec_capybara_assignment.rb:6:in<顶部(必需(>'

在0.7789秒内完成(文件加载耗时3.61秒(1个示例,1个故障

失败示例:

rspec/spec/tests/rspec_capibara\assignment.rb:5#打开自动化实践站点测试:页面内容

这似乎与硒网络驱动程序有关,而不是水豚本身。

上有一个关于此的问题https://github.com/SeleniumHQ/selenium/issues/7365

要修复此问题,请在您的gemfile中指定您想要的最低3.142.4:gem 'selenium-webdriver', '~> 3.142.4'

然后运行bundle update selenium-webdriver

这应该能解决这个具体问题。

最新更新