Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'rubygems'
require 'spec'
require 'watir'

Watir::Browser.default = 'safari'
browser = Watir::Browser.new
browser.goto("http://localhost:8888/")

describe "My WordPress home page" do
  it "should find the header" do
    browser.div(:id, "header").exist?.should == true
  end
  it "should find the default entry" do
    browser.div(:id, "post-1").exists?.should == true
    browser.div(:id, "post-1").text.include?("Hello world!").should == true
  end
end

describe "Write a post" do
  if browser.link(:text, "Log out").exists? == false
    it "should go to login page" do
      browser.link(:text, "Log in").exists?.should == true
      browser.link(:text, "Log in").click
    end
    it "should log in" do
      browser.text_field(:id, "user_login").set("admin")
      browser.text_field(:id, "user_pass").set("lVm8R52!0W1O")
      browser.button(:id, "wp-submit").click
    end
  else
    it "should go to admin page" do
      browser.goto("http://localhost:8888/wp-admin/")
    end
  end
  it "should write a quick post" do
    browser.div(:id, "dashboard_quick_press").exists?.should == true
    browser.text_field(:id, "title").set("This is a test post")
    browser.text_field(:id, "content").set("I have lots of great things to say.")
    browser.text_field(:id, "tags-input").set("testing")
    browser.button(:id, "publish").click
  end
  it "should log out" do
    browser.link(:text, "Log Out").exists?.should == true
    browser.link(:text, "Log Out").click
  end
end