2017-03-20 18:21:26 +13:00
|
|
|
|
require 'selenium-webdriver'
|
|
|
|
|
require 'rspec/expectations'
|
|
|
|
|
include RSpec::Matchers
|
|
|
|
|
|
|
|
|
|
def setup
|
2017-03-20 18:34:42 +13:00
|
|
|
|
caps = Selenium::WebDriver::Remote::Capabilities.send("chrome")
|
|
|
|
|
@driver = Selenium::WebDriver.for(:remote, url: "http://0.0.0.0:4444/wd/hub", desired_capabilities: caps)
|
|
|
|
|
@driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)
|
2017-03-20 18:21:26 +13:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def teardown
|
2017-03-20 18:34:42 +13:00
|
|
|
|
@driver.quit
|
2017-03-20 18:21:26 +13:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def run
|
2017-03-20 18:34:42 +13:00
|
|
|
|
setup
|
|
|
|
|
yield
|
|
|
|
|
teardown
|
2017-03-20 18:21:26 +13:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
run do
|
2017-03-20 18:34:42 +13:00
|
|
|
|
container_ip = ARGV[0]
|
2017-03-20 18:21:26 +13:00
|
|
|
|
|
2017-03-20 18:34:42 +13:00
|
|
|
|
puts "Running tests against container IP: #{container_ip}"
|
2017-03-20 18:21:26 +13:00
|
|
|
|
|
2017-03-20 18:34:42 +13:00
|
|
|
|
# Open the main page and check for the title
|
|
|
|
|
site_url = "http://#{container_ip}"
|
|
|
|
|
@driver.get site_url + '/'
|
|
|
|
|
#@driver.save_screenshot(File.join(Dir.pwd, "selenium-docker-main-page.png"))
|
|
|
|
|
expect(@driver.title).to eql 'wp plugindev – Just another WordPress site'
|
2017-03-20 18:21:26 +13:00
|
|
|
|
|
2017-03-20 18:34:42 +13:00
|
|
|
|
puts 'Title test OK'
|
2017-03-20 18:21:26 +13:00
|
|
|
|
|
|
|
|
|
|
2017-03-20 18:34:42 +13:00
|
|
|
|
@driver.get site_url + '/wp-admin'
|
2017-03-20 18:21:26 +13:00
|
|
|
|
|
2017-03-20 18:34:42 +13:00
|
|
|
|
@driver.find_element(name: 'log').send_keys 'admin'
|
|
|
|
|
@driver.find_element(name: 'pwd').send_keys 'admin'
|
|
|
|
|
@driver.find_element(name: 'wp-submit').submit
|
|
|
|
|
|
|
|
|
|
expect(@driver.title).to eql 'Dashboard ‹ wp plugindev — WordPress'
|
|
|
|
|
|
|
|
|
|
puts 'Login test OK'
|
|
|
|
|
|
|
|
|
|
@driver.get site_url + '/wp-admin/tools.php?page=wp-static-html-output-options'
|
|
|
|
|
|
|
|
|
|
# setup export and run
|
|
|
|
|
|
|
|
|
|
# get list of files from export folder (should be only one exported folder)
|
|
|
|
|
|
|
|
|
|
# check contents of index.html file
|
|
|
|
|
|
|
|
|
|
## Generate a screenshot of the checkbox page
|
|
|
|
|
@driver.save_screenshot(File.join(Dir.pwd, "selenium-docker-plugin-settings.png"))
|
2017-03-20 18:21:26 +13:00
|
|
|
|
end
|