I'm attempting to determine after a page loads whether text within a script may be located using Watir WebDriver. I am using Watir-WebDriver to automate our test effort. I cannot figure out how to locate the element and verify the value. Any help?
<script><!--
...
s.events="event9"
...
//--></script>
So, I guess I'm wondering is it possible to search for text within a HTML script using watir webdriver?
Thank you in advance.
UPDATE: Below is the script.
require "rubygems"
require "watir-webdriver"
require "watir-webdriver-performance"
require "rspec"
require "headless"
include Watir
require 'logger'
#path store file: script, data file, logs
path = File.dirname(__FILE__)
#create log file
name_log = 'TEST_0001_bsro_validation_suite'
file = File.open(path + '/logs/' + name_log + '_logFile.log', File::WRONLY | File::APPEND | File::CREAT)
logger = Logger.new(file)
logger.info("=> TEST: 0004_bsro_validation")
#open internet browser
browser = Watir::Browser.new :ff
#go to rebrand website with login info. this may need to be removed.
test_site = 'http://*****:*****@fcac-rebrand.laughlin.com/'
browser.goto(test_site)
load_secs = browser.performance.summary[:response_time]
logger.info("=> Page Load Time: #{load_secs}")
zipcode_input = browser.text_field(:id => 'universal-selectorZip')
# select year; progressive selection
year_select = browser.select_list(:id => 'universal-year')
browser.select_list(:id => 'universal-year', :disabled => 'disabled').wait_while_present
if year_select.exists?
year_select.select '2010'
else
logger.info("=> ERROR: Year Select Not Available")
end
# select make; progressive selection
make_select = browser.select_list(:id => 'universal-make')
browser.select_list(:id => 'universal-make', :disabled => 'disabled').wait_while_present
if make_select.exists?
make_select.select 'Volkswagen'
else
logger.info("=> ERROR: Make Select Not Available")
end
# select model; progressive selection
model_select = browser.select_list(:id => 'universal-model')
browser.select_list(:id => 'universal-model', :disabled => 'disabled').wait_while_present
if model_select.exists?
model_select.select 'Jetta'
else
logger.info("=> ERROR: Model Select Not Available")
end
# select submodel; progressive selection
submodel_select = browser.select_list(:id => 'universal-submodel')
browser.select_list(:id => 'universal-submodel', :disabled => 'disabled').wait_while_present
if submodel_select.exists?
submodel_select.select '2.0T TDI Sedan'
else
logger.info("=> ERROR: Submodel Select Not Available")
end
# input zip code; progressive selection
if zipcode_input.exists?
zipcode_input.set '53202'
else
logger.info("=> ERROR: ZIP Code Select Not Available")
end
browser.button(:id => 'universal-submit-tires-quote').click
browser.script.html.include? "event49"
browser.close
I should add that the event is event49 not 9 in this case. Thanks!