加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby轨道 – 黄瓜Webrat硒指南

发布时间:2020-12-16 19:35:43 所属栏目:百科 来源:网络整理
导读:我一直在使用黄瓜和Webrat一段时间.我现在需要开始编写涉及 AJAX交互的行为,所以我正在考虑使用Webrat的Selenium适配器. 任何人都可以指出安装和配置硒webrat黄瓜的简单和更新的分步指南? 我想要将 javascript场景与非javascript场景混合在一起. 解决方法
我一直在使用黄瓜和Webrat一段时间.我现在需要开始编写涉及 AJAX交互的行为,所以我正在考虑使用Webrat的Selenium适配器.
任何人都可以指出安装和配置硒webrat黄瓜的简单和更新的分步指南?
我想要将 javascript场景与非javascript场景混合在一起.

解决方法

我在我的项目中使用Sspium与rspec,并从Selenium IDE的自定义格式化器生成代码.

有很多硒的铁轨,但我成功使用Selenium-RC http://seleniumhq.org/download/,所以下载到你的电脑.

这是我的步骤:

>解压缩并运行> java -jar selenium-server.jar
>打开selenium-client-ruby,阅读文档,按照你会得到成功!
> gem安装rspec,rspec-rails版本1.2.6(不需要,你需要注释版本限制的selenium-client源代码)
宝石安装selenium-client
>打开Selenium-IDE(当然是Firefox),打开选项 – >选项 – >格式
>单击添加,并将此代码粘贴到http://www.techdarkside.com/rspec_export.txt

现在,您只需将规格导出到您的spec文件夹,我使用spec / features / xxxx_spec.rb,请参阅下面的代码.

非常类似的方法可以在here找到

对于webrat黄瓜,最新的Rspec book将给你所需要的. (他们没有硒黄瓜章节完成)

require 'rubygems'
gem "rspec","=1.2.6"
gem "selenium-client",">=1.2.15"
require "selenium/client"
require "selenium/rspec/spec_helper"

describe "Google Search" do
    attr_reader :selenium_driver
    alias :page :selenium_driver

  before(:all) do
      @selenium_driver = Selenium::Client::Driver.new 
          :host => "localhost",:port => 4444,:browser => "*firefox",:url => "http://www.google.com",:timeout_in_second => 60
  end

  before(:each) do
    selenium_driver.start_new_browser_session
  end

  # The system capture need to happen BEFORE closing the Selenium session
  append_after(:each) do
    @selenium_driver.close_current_browser_session
  end

  it "can find Selenium" do
    page.open "/"
    page.title.should eql("Google")
    page.type "q","Selenium seleniumhq"
    page.click "btnG",:wait_for => :page
    page.value("q").should eql("Selenium seleniumhq")
    page.text?("seleniumhq.org").should be_true
    page.title.should eql("Selenium seleniumhq - Google Search")
    page.text?("seleniumhq.org").should be_true
            page.element?("link=Cached").should be_true
  end

end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读