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
|
return driver
|
||||||
|
|
||||||
def _create_driver_remote_chromium2(self, session_name):
|
def _create_driver_remote_chromium2(self, session_name):
|
||||||
print('got this far', session_name)
|
|
||||||
fp = None
|
fp = None
|
||||||
drivers = {}
|
drivers = {}
|
||||||
try:
|
try:
|
||||||
@ -210,11 +209,11 @@ class BrowserProxy:
|
|||||||
drivers = pickle.load(fp)
|
drivers = pickle.load(fp)
|
||||||
if not drivers:
|
if not drivers:
|
||||||
raise Exception
|
raise Exception
|
||||||
LOGGER.debug('found pickled drivers')
|
LOGGER.debug('found pickled drivers: %s', drivers.keys())
|
||||||
driver = drivers.get(session_name)
|
driver = drivers.get(session_name)
|
||||||
if not driver:
|
if not driver:
|
||||||
raise Exception
|
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
|
url = driver.current_url # throw error if driver isn't reliable anymore
|
||||||
LOGGER.info('webdriver instance is ready')
|
LOGGER.info('webdriver instance is ready')
|
||||||
self.driver = driver
|
self.driver = driver
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
|
import selenium
|
||||||
|
import time
|
||||||
|
|
||||||
LOGGER = logging.getLogger('wabot')
|
LOGGER = logging.getLogger('wabot')
|
||||||
|
|
||||||
class PageObject:
|
class PageObject:
|
||||||
@ -56,7 +60,7 @@ class TextField(PageObject):
|
|||||||
return self.page.get_el_value(self.el)
|
return self.page.get_el_value(self.el)
|
||||||
|
|
||||||
def set_value(self, value):
|
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))
|
time.sleep(random.uniform(3,5))
|
||||||
return self.page.set_el_value(self.el, value)
|
return self.page.set_el_value(self.el, value)
|
||||||
|
|
||||||
@ -72,7 +76,7 @@ class SelectField(PageObject):
|
|||||||
return self.page.get_select_value(self.dropdown)
|
return self.page.get_select_value(self.dropdown)
|
||||||
|
|
||||||
def set_value(self, value):
|
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))
|
time.sleep(random.uniform(6,11))
|
||||||
return self.page.set_select_value(self.dropdown, value)
|
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)
|
return self.page.get_checkbox_value(self.el, ignore)
|
||||||
|
|
||||||
def set_checked(self, checked):
|
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))
|
time.sleep(random.uniform(2,3))
|
||||||
return self.page.set_checkbox(self.el, checked)
|
return self.page.set_checkbox(self.el, checked)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class Page:
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.driver = parent.driver
|
self.driver = parent.driver
|
||||||
LOGGER.info('Loaded Page()')
|
LOGGER.info("Loaded Page() '%s'", self.__class__.__name__)
|
||||||
|
|
||||||
def find_element_locators(self, key):
|
def find_element_locators(self, key):
|
||||||
"""
|
"""
|
||||||
@ -273,12 +273,12 @@ class Page:
|
|||||||
actions.perform()
|
actions.perform()
|
||||||
except Exception as ex: # type is selenium timeout... not sure
|
except Exception as ex: # type is selenium timeout... not sure
|
||||||
print(ex)
|
print(ex)
|
||||||
nhsn_lo.pages.logger.error("%s" % (ex))
|
LOGGER.error("%s" % (ex))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def save_screenshot(self, filename):
|
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,
|
# Chromium2 screenshot only captures viewable area,
|
||||||
@ -408,13 +408,13 @@ class Page:
|
|||||||
el.send_keys(ch)
|
el.send_keys(ch)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except Exception as ex:
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
el.send_keys(value)
|
el.send_keys(value)
|
||||||
except Exception as ex:
|
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
|
return False
|
||||||
|
|
||||||
el_value = self.get_el_value(el)
|
el_value = self.get_el_value(el)
|
||||||
@ -428,7 +428,7 @@ class Page:
|
|||||||
|
|
||||||
def get_select_value(self, select):
|
def get_select_value(self, select):
|
||||||
if not 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
|
return None
|
||||||
try:
|
try:
|
||||||
value = select.first_selected_option.get_attribute("value")
|
value = select.first_selected_option.get_attribute("value")
|
||||||
@ -439,7 +439,7 @@ class Page:
|
|||||||
def set_select_value(self, select, value=None, text=None):
|
def set_select_value(self, select, value=None, text=None):
|
||||||
if not select:
|
if not select:
|
||||||
return False
|
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)))
|
# % (value, self.get_el_identifier(select._el)))
|
||||||
if value:
|
if value:
|
||||||
try:
|
try:
|
||||||
@ -461,11 +461,11 @@ class Page:
|
|||||||
return False
|
return False
|
||||||
if checked:
|
if checked:
|
||||||
if not is_selected:
|
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)
|
self.click(el)
|
||||||
else:
|
else:
|
||||||
if is_selected:
|
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)
|
self.click(el)
|
||||||
val = self.get_checkbox_value(el)
|
val = self.get_checkbox_value(el)
|
||||||
if val != checked:
|
if val != checked:
|
||||||
@ -516,10 +516,10 @@ class Page:
|
|||||||
alert.accept()
|
alert.accept()
|
||||||
else:
|
else:
|
||||||
alert.dismiss()
|
alert.dismiss()
|
||||||
nhsn_lo.pages.logger.trace('caught js alert: %s' % text)
|
LOGGER.trace('caught js alert: %s' % text)
|
||||||
return text
|
return text
|
||||||
except selenium.common.exceptions.TimeoutException:
|
except selenium.common.exceptions.TimeoutException:
|
||||||
nhsn_lo.pages.logger.trace('no js alert present')
|
LOGGER.trace('no js alert present')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_element_stale(self, webelement):
|
def is_element_stale(self, webelement):
|
||||||
|
Loading…
Reference in New Issue
Block a user