-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from o19s/api_key
Api key
- Loading branch information
Showing
4 changed files
with
112 additions
and
31 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
#!/usr/bin/env ruby | ||
require 'rubygems' | ||
require_relative '../lib/agent_q' | ||
require_relative '../lib/check_case' | ||
require_relative '../lib/run_queries' | ||
|
||
quepid_case = ARGV[0] | ||
threshold_score = ARGV[1] | ||
username = ARGV[2] | ||
password = ARGV[3] | ||
quepid_url = ARGV[4] | ||
subcommand = ARGV[0] | ||
|
||
if subcommand == 'check-case' | ||
quepid_case = ARGV[1] | ||
threshold_score = ARGV[2] | ||
username = ARGV[3] | ||
password = ARGV[4] | ||
quepid_url = ARGV[5] | ||
|
||
CheckCase.new(quepid_case, threshold_score, username, password, quepid_url).run | ||
end | ||
|
||
|
||
AgentQ.new(quepid_case, threshold_score, username, password, quepid_url).run | ||
if subcommand == 'run-queries' | ||
quepid_case = ARGV[1] | ||
username = ARGV[2] | ||
password = ARGV[3] | ||
quepid_url = ARGV[4] | ||
|
||
RunQueries.new(quepid_case, username, password, quepid_url).run | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Inspired by http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html | ||
|
||
require 'capybara' | ||
require 'capybara/dsl' | ||
require 'capybara/cuprite' | ||
require 'json' | ||
|
||
class RunQueries | ||
include Capybara::DSL | ||
|
||
|
||
def initialize(quepid_case, username, password, quepid_url) | ||
@quepid_case = quepid_case | ||
@username = username | ||
@password = password | ||
@quepid_url = quepid_url | ||
|
||
Capybara.register_driver :cuprite do |app| | ||
Capybara::Cuprite::Driver.new(app, timeout: 30) # Increase timeout to 30 seconds | ||
end | ||
|
||
Capybara.default_driver = :cuprite | ||
Capybara.default_max_wait_time = 30 # Increase timeout to 30 seconds | ||
# Capybara.app_host = @quepid_url | ||
end | ||
|
||
def run | ||
|
||
# we go direct to the case, which then prompts the login process. That way we only | ||
# score the requested case | ||
visit("#{@quepid_url}/case/#{@quepid_case}/query/0") | ||
save_screenshot('quepid.png') | ||
within('#login') do | ||
fill_in('user_email', with: @username) | ||
fill_in('user_password', with: @password) | ||
|
||
click_button('Sign in') | ||
end | ||
save_screenshot('quepid_login.png') | ||
|
||
|
||
|
||
visit("#{@quepid_url}/case/#{@quepid_case}/query/0") | ||
|
||
|
||
|
||
save_screenshot('quepid_case_queries.png') | ||
|
||
page.has_css?('.search-feedback', visible: true, wait: 60) | ||
|
||
save_screenshot('quepid_case_queries2.png') | ||
|
||
page.has_no_css?('.search-feedback', wait: 60) | ||
|
||
save_screenshot('quepid_case_queries3.png') | ||
|
||
content = find('.snapshot-payload').text | ||
|
||
puts content | ||
|
||
|
||
end | ||
|
||
end |