mirror of
https://git.zavage.net/Zavage-Software/wabot.git
synced 2024-12-22 18:39:20 -07:00
updated reference to new logger
This commit is contained in:
parent
1208b6b306
commit
b64cd13525
@ -202,7 +202,6 @@ class BrowserProxy:
|
||||
return driver
|
||||
|
||||
def _create_driver_remote_chromium2(self, session_name):
|
||||
print('got this far', session_name)
|
||||
fp = None
|
||||
drivers = {}
|
||||
try:
|
||||
@ -210,11 +209,11 @@ class BrowserProxy:
|
||||
drivers = pickle.load(fp)
|
||||
if not drivers:
|
||||
raise Exception
|
||||
LOGGER.debug('found pickled drivers')
|
||||
LOGGER.debug('found pickled drivers: %s', drivers.keys())
|
||||
driver = drivers.get(session_name)
|
||||
if not driver:
|
||||
raise Exception
|
||||
LOGGER.debug('connected to pickled webdriver instance')
|
||||
LOGGER.debug('connected to pickled webdriver instance: %s', session_name)
|
||||
url = driver.current_url # throw error if driver isn't reliable anymore
|
||||
LOGGER.info('webdriver instance is ready')
|
||||
self.driver = driver
|
||||
|
@ -1,4 +1,8 @@
|
||||
import logging
|
||||
import random
|
||||
import selenium
|
||||
import time
|
||||
|
||||
LOGGER = logging.getLogger('wabot')
|
||||
|
||||
class PageObject:
|
||||
@ -56,7 +60,7 @@ class TextField(PageObject):
|
||||
return self.page.get_el_value(self.el)
|
||||
|
||||
def set_value(self, value):
|
||||
LOGGER.info('<%s> set_text (%s)' % (self.name, value))
|
||||
LOGGER.info('[%s]->set_text (%s)' % (self.name, value))
|
||||
time.sleep(random.uniform(3,5))
|
||||
return self.page.set_el_value(self.el, value)
|
||||
|
||||
@ -72,7 +76,7 @@ class SelectField(PageObject):
|
||||
return self.page.get_select_value(self.dropdown)
|
||||
|
||||
def set_value(self, value):
|
||||
LOGGER.info('<%s> set_select (%s)' % (self.name, value))
|
||||
LOGGER.info('[%s]->set_select (%s)' % (self.name, value))
|
||||
time.sleep(random.uniform(6,11))
|
||||
return self.page.set_select_value(self.dropdown, value)
|
||||
|
||||
@ -90,7 +94,7 @@ class CheckField(PageObject):
|
||||
return self.page.get_checkbox_value(self.el, ignore)
|
||||
|
||||
def set_checked(self, checked):
|
||||
LOGGER.info('<%s> set_checked (%s)' % (self.name, checked))
|
||||
LOGGER.info('[%s]->set_checked (%s)' % (self.name, checked))
|
||||
time.sleep(random.uniform(2,3))
|
||||
return self.page.set_checkbox(self.el, checked)
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Page:
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.driver = parent.driver
|
||||
LOGGER.info('Loaded Page()')
|
||||
LOGGER.info("Loaded Page() '%s'", self.__class__.__name__)
|
||||
|
||||
def find_element_locators(self, key):
|
||||
"""
|
||||
@ -273,12 +273,12 @@ class Page:
|
||||
actions.perform()
|
||||
except Exception as ex: # type is selenium timeout... not sure
|
||||
print(ex)
|
||||
nhsn_lo.pages.logger.error("%s" % (ex))
|
||||
LOGGER.error("%s" % (ex))
|
||||
return False
|
||||
return True
|
||||
|
||||
def save_screenshot(self, filename):
|
||||
nhsn_lo.pages.logger.info("saving page screenshot: %s" % (filename))
|
||||
LOGGER.info("saving page screenshot: %s" % (filename))
|
||||
|
||||
|
||||
# Chromium2 screenshot only captures viewable area,
|
||||
@ -408,13 +408,13 @@ class Page:
|
||||
el.send_keys(ch)
|
||||
time.sleep(1)
|
||||
except Exception as ex:
|
||||
nhsn_lo.pages.logger.error("failed to send keys, element in unknown state!!: %s" % (ex))
|
||||
LOGGER.error("failed to send keys, element in unknown state!!: %s" % (ex))
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
el.send_keys(value)
|
||||
except Exception as ex:
|
||||
nhsn_lo.pages.logger.error("failed to send keys, element in unknown state!!: %s" % (ex))
|
||||
LOGGER.error("failed to send keys, element in unknown state!!: %s" % (ex))
|
||||
return False
|
||||
|
||||
el_value = self.get_el_value(el)
|
||||
@ -428,7 +428,7 @@ class Page:
|
||||
|
||||
def get_select_value(self, select):
|
||||
if not select:
|
||||
nhsn_lo.pages.logger.error("tried to get select value of NULL element")
|
||||
LOGGER.error("tried to get select value of NULL element")
|
||||
return None
|
||||
try:
|
||||
value = select.first_selected_option.get_attribute("value")
|
||||
@ -439,7 +439,7 @@ class Page:
|
||||
def set_select_value(self, select, value=None, text=None):
|
||||
if not select:
|
||||
return False
|
||||
# nhsn_lo.pages.logger.trace("setting select value (%s) for (%s)"\
|
||||
# LOGGER.trace("setting select value (%s) for (%s)"\
|
||||
# % (value, self.get_el_identifier(select._el)))
|
||||
if value:
|
||||
try:
|
||||
@ -461,11 +461,11 @@ class Page:
|
||||
return False
|
||||
if checked:
|
||||
if not is_selected:
|
||||
# nhsn_lo.pages.logger.trace("checking unchecked box (%s)" % (self.get_el_identifier(el)))
|
||||
# LOGGER.trace("checking unchecked box (%s)" % (self.get_el_identifier(el)))
|
||||
self.click(el)
|
||||
else:
|
||||
if is_selected:
|
||||
# nhsn_lo.pages.logger.trace("unchecking checked box (%s)" % (self.get_el_identifier(el)))
|
||||
# LOGGER.trace("unchecking checked box (%s)" % (self.get_el_identifier(el)))
|
||||
self.click(el)
|
||||
val = self.get_checkbox_value(el)
|
||||
if val != checked:
|
||||
@ -516,10 +516,10 @@ class Page:
|
||||
alert.accept()
|
||||
else:
|
||||
alert.dismiss()
|
||||
nhsn_lo.pages.logger.trace('caught js alert: %s' % text)
|
||||
LOGGER.trace('caught js alert: %s' % text)
|
||||
return text
|
||||
except selenium.common.exceptions.TimeoutException:
|
||||
nhsn_lo.pages.logger.trace('no js alert present')
|
||||
LOGGER.trace('no js alert present')
|
||||
return False
|
||||
|
||||
def is_element_stale(self, webelement):
|
||||
|
Loading…
Reference in New Issue
Block a user