栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

selenium+ Webrat +selenium指南

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

selenium+ Webrat +selenium指南

我在项目上将Selenium与rspec结合使用,并从Selenium IDE的自定义格式化程序生成代码。

硒有很多,但是我使用Selenium-
RC成功http://seleniumhq.org/download/,所以请下载到您的PC。

这是我的步骤:

  1. 解压缩并运行> java -jar selenium-server.jar
  2. 打开selenium-client-ruby,阅读文档,跟随它,您将获得成功!
  3. gem install rspec,rspec-rails版本1.2.6(不是,您需要注释selenium-client源代码的版本限制)
  4. gem install硒客户端
  5. 打开Selenium-IDE(当然是Firefox),打开选项->选项->格式
  6. 单击添加,然后将此代码粘贴到http://www.techdarkside.com/rspec_export.txt中

现在,您只需要为我导出规范到您的规范文件夹,我就使用spec / features / xxxx_spec.rb参见下面的代码。

在这里可以找到非常相似的方法

对于webrat + cucumber,最新的Rspec手册将为您提供所需的一切。(他们还没有硒+黄瓜章节完成)

 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  endend


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/623928.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号