-
-
Save anonymous/6586facc7e79a35cf6f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'selenium-webdriver' | |
require '../../../lib/Utils' | |
require '../../../lib/Portal/Session' | |
require '../../../lib/Log' | |
require '../../../lib/Portal/UI/Navigation' | |
class SearchTest < MiniTest::Unit::TestCase | |
# Called before every test method runs. Can be used | |
# to set up fixture information. | |
def setup | |
p "a" | |
@waiter = Selenium::WebDriver::Wait.new(:timeout => 20) | |
@driver = Selenium::WebDriver.for :firefox | |
@driver.navigate.to "SOMEURL" | |
@waiter.until{ @driver.find_element(:css, "input[type='password']") } | |
if user != '' | |
@driver.find_element(:id, "username").send_keys('user') | |
end | |
if pass != '' | |
@driver.find_element(:css, "input[type='password']").send_keys('password') | |
end | |
driver.find_element(:css, "input[type='submit']").click | |
Sel_Utils::Sel_Utils.loading? | |
@waiter.until{@driver.find_elements(:css, ".n-dashboardscreen") } | |
Sel_Utils::Sel_Utils.ClickObject("css", "#subtab-overview-label") | |
Sel_Utils::Sel_Utils.loading? | |
end | |
end | |
# Called after every test method runs. Can be used to tear | |
# down fixture information. | |
def teardown | |
driver.quit | |
end | |
# Fake test | |
def test_search_positive | |
assert(@driver.find_element(:css, ".n-input"), "Search Rows input box exists") | |
assert_equal(@driver.find_element(:css, ".n-input").attribute("value"),"Search Rows","Search Rows default text is Search Rows") | |
@driver.find_element(:css, ".n-input").SendKeys("Automation" + :enter) | |
sleep 2 | |
@driver.find_elements(:css, ".sites-link").each{|site| | |
if !site.attribute("title").include?("Automation") | |
fail("Found a site that did not match search params") | |
end | |
} | |
pass("All sites contain search param") | |
end | |
def test_search_negative | |
@driver.find_element(:css, ".n-input").SendKeys("NonExistantSite" + :enter) | |
assert_equal(@driver.find_elements(:css, ".sites-link").count, 0, "No sites found as expected") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment