Class: CatGem

Inherits:
Object
  • Object
show all
Defined in:
lib/catgem.rb

Instance Method Summary collapse

Instance Method Details

#cat_sleep(secs) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/catgem.rb', line 28

def cat_sleep(secs)
  # todo replace sleep with something better at a later date

  # for now break the sleep into 0.5 second chucks to stop CPU becoming locked

  puts("Inside " + __method__.to_s)
  counter = secs * 2
  counter.times {sleep(0.5)}
end

#check_for_firefox(browser) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/catgem.rb', line 36

def check_for_firefox(browser)
  # check which browser is running

  # if firefox add the dreaded sleep at selected points

  # to assist with firefox slowness

  #

  if(browser.driver.browser.to_s.downcase == "firefox")
 puts("Inside " + __method__.to_s)
    cat_sleep 2
  end
end

#doc_count(browser) ⇒ Object



23
24
25
26
# File 'lib/catgem.rb', line 23

def doc_count(browser)
  puts("Inside " + __method__.to_s)
  browser.divs(:class => ['col-12','col-sm-6','my-2','ng-star-inserted']).count
end

#fill_text_box(the_text, the_field, browser) ⇒ Object



17
18
19
20
21
# File 'lib/catgem.rb', line 17

def fill_text_box(the_text,the_field, browser)
  puts("Inside " + __method__.to_s)
  # populate using java script, much faster

  browser.execute_script("arguments[0].value = '#{the_text}';", the_field)
end

#login_if_required(username, password, browser) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/catgem.rb', line 8

def (username, password, browser)
  # if re-directed to the login page

  # do as requested and login

  puts("Inside " + __method__.to_s + " with username " + username + " and password " + password)
  if browser.text_field(:id => "username").present?
    (username, password, browser)
  end
end

#login_members_portal(username, password, browser) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/catgem.rb', line 47

def (username, password, browser)
  # login to the trades portal

  puts("Inside " + __method__.to_s + " with username " + username + " and password " + password)
  cat_sleep 2
  browser.text_field(:id => "username").set username
  browser.text_field(:id => "password").set password
  #sometimes this process can be very slow on preview, so allow a little sleep

  cat_sleep 2
  browser.button(:class => 'btn-primary').click
end

#login_members_portal_rename(username, password, tempusername, browser) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/catgem.rb', line 58

def (username, password, tempusername, browser)
  puts("Inside " + __method__.to_s + " with username " + username + " and password " + password + " and temp username " + tempusername)
  (username, password, browser)
  # unable to use a wait here because depending on result

  # different pages could be visible, so sleep is only option

  cat_sleep 3
  if browser.div(:class => 'alert-danger').present?
    #unable to login, try standard username

    (FigNewton::tempusername, password, browser)
  end
end

#return_current_monthObject



3
4
5
6
# File 'lib/catgem.rb', line 3

def return_current_month
  month = Date.today.strftime("%m")
  month
end