Ruby 冻结错误可以';不要修改冻结字符串
运行下面提到的代码时出现冻结错误。还可以查找帮助文件。以下是主文件: 需要“spec\u helper.rb” 需要“rspec\u capybara\u assignment\u helper.rb”Ruby 冻结错误可以';不要修改冻结字符串,ruby,rspec,capybara,Ruby,Rspec,Capybara,运行下面提到的代码时出现冻结错误。还可以查找帮助文件。以下是主文件: 需要“spec\u helper.rb” 需要“rspec\u capybara\u assignment\u helper.rb” describe 'Open the automationpractices site' , :type => :request do it 'Test: Page Content', :page do visit "http://automationpr
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\u Helper文件:-Spec\u 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
错误如下:
打开automationpractices站点
测试:页面内容(失败-1)
失败:
rspec./spec/tests/rspec_capybara_assignment.rb:5#打开automationpractices站点测试:页面内容这似乎与selenium webdriver有关,而不是与capybara本身有关 关于这一点,目前有一个问题 要修复此问题,请在gem文件中指定至少需要3.142.4版本:
gem'selenium webdriver',“~>3.142.4”
然后运行bundle update selenium webdriver
这应该可以解决这个特定的问题。这似乎与selenium webdriver有关,而不是水豚本身 关于这一点,目前有一个问题 要修复此问题,请在gem文件中指定至少需要3.142.4版本:
gem'selenium webdriver',“~>3.142.4”
然后运行bundle update selenium webdriver
这应该可以解决这个特定问题。您能显示完整的错误,以及错误来自更新的代码的哪一行吗。您使用的是什么版本的Capybara?Capybara(3.33.0,3.32.2)Capybara屏幕截图(1.0.24)您能否显示完整的错误以及错误来自更新代码的哪一行。您使用的是哪一版本的Capybara?Capybara(3.33.0,3.32.2)Capybara屏幕截图(1.0.24)
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