<commit_before>def webseal_login_check
  if page.has_content?("Sign in with your Land Registry account")
    fill_in 'username', with: $WEBSEAL_LOGIN
    fill_in 'password', with: <PASSWORD>
    click_button('Sign In')
    if page.has_content?("You are already logged in from another client")
        click_link('Terminate existing login')
    end
  end
end

def purchase_title_summary(title_number)
  visit_title_confirmation_page(title_number)
  pay_for_title_to_view_summary
end

def check_title_search_page_is_displayed
  expect(page).to have_selector('h1', text: 'Search the land and property register')
end

def visit_title_register_page(title_number)
  purchase_title_summary(title_number)
  #page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  #page.visit("#{$DIGITAL_REGISTER_URL}/titles/#{title_number}")
  #webseal_login_check
end

def visit_cookie_page
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/cookies")
  webseal_login_check
end

def visit_landing_page
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/landing-page")
  webseal_login_check
end

def visit_property_search_page
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/title-search")
  webseal_login_check
end

def visit_title_confirmation_page(title_number)
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/confirm-selection/#{title_number}/PLYMOUTH?display_page_number=1")
  webseal_login_check
end

def check_title_summary_page_is_displayed
  expect(content).to include 'Summary of title'
end

def check_title_confirmation_page_is_displayed
  expect(content).to include 'Confirm your order'
end

def pay_for_title_to_view_summary
  check("right_to_cancel")
  find(".button", :text => "Buy title summary").click
end

def current_page_number
  page_text = page.find('#pagination').text
  page_text.split(' ')[1].to_i
end

def visit_title_register_pdf(title_number)
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  page.visit("#{$DIGITAL_REGISTER_URL}/titles/#{title_number}.pdf")
  webseal_login_check

  cookie = grab_cookies

  pdf_content = get_register_pdf(title_number, cookie)

  save_pdf_file(pdf_content)
end

# gets the cookies from the capybara session
def grab_cookies
  cookie = []
  Capybara.current_session.driver.cookies.each do |key, value|
    cookie.push(key + '=' + value.value)
  end
  cookie
end
<commit_msg>pdf stuff<commit_after>def webseal_login_check
  if page.has_content?("Sign in with your Land Registry account")
    fill_in 'username', with: $WEBSEAL_LOGIN
    fill_in 'password', with: <PASSWORD>
    click_button('Sign In')
    if page.has_content?("You are already logged in from another client")
        click_link('Terminate existing login')
    end
  end
end

def purchase_title_summary(title_number)
  visit_title_confirmation_page(title_number)
  pay_for_title_to_view_summary
end

def check_title_search_page_is_displayed
  expect(page).to have_selector('h1', text: 'Search the land and property register')
end

def visit_title_register_page(title_number)
  purchase_title_summary(title_number)
  #page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  #page.visit("#{$DIGITAL_REGISTER_URL}/titles/#{title_number}")
  #webseal_login_check
end

def visit_cookie_page
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/cookies")
  webseal_login_check
end

def visit_landing_page
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/landing-page")
  webseal_login_check
end

def visit_property_search_page
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/title-search")
  webseal_login_check
end

def visit_title_confirmation_page(title_number)
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  visit("#{$DIGITAL_REGISTER_URL}/confirm-selection/#{title_number}/PLYMOUTH?display_page_number=1")
  webseal_login_check
end

def check_title_summary_page_is_displayed
  expect(content).to include 'Summary of title'
end

def check_title_confirmation_page_is_displayed
  expect(content).to include 'Confirm your order'
end

def pay_for_title_to_view_summary
  check("right_to_cancel")
  find(".button", :text => "Buy title summary").click
end

def current_page_number
  page_text = page.find('#pagination').text
  page_text.split(' ')[1].to_i
end

def visit_title_register_pdf(title_number)
  page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34", "Referer" => "", "iv-user" => "tester_user", "iv-groups" => "drv" }
  purchase_title_summary
  page.visit("#{$DIGITAL_REGISTER_URL}/titles/#{title_number}.pdf")

  cookie = grab_cookies

  pdf_content = get_register_pdf(title_number, cookie)

  save_pdf_file(pdf_content)
end

# gets the cookies from the capybara session
def grab_cookies
  cookie = []
  Capybara.current_session.driver.cookies.each do |key, value|
    cookie.push(key + '=' + value.value)
  end
  cookie
end

{'fraction_non_alphanumeric': 0.14640522875816994, 'fraction_numerical': 0.03224400871459695, 'mean_word_length': 5.375925925925926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7578651', 'n_tokens_mistral': 2700, 'n_tokens_neox': 2538, 'n_words': 485}