log double data error and too many requests error
This commit is contained in:
@@ -22,6 +22,8 @@ OTP_FIELD_ID = "#sms_code"
|
||||
MESSAGE_FIELD_CLASS = ".message"
|
||||
|
||||
CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been registered"
|
||||
DOUBLE_REQUEST_ERROR_MESSAGE = "A request with the same data has already been validated today."
|
||||
TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
||||
TIME_OUT = 400000
|
||||
OTP_TIMEOUT = 240
|
||||
|
||||
@@ -152,7 +154,7 @@ class CommandorPage:
|
||||
if CONFIRMED_MESSAGE in message:
|
||||
# publish the successful message
|
||||
self.publish_message_to_queue(self.contact, PublishType.SUCCESS, self.page.url)
|
||||
self.getErrors()
|
||||
self.get_errors()
|
||||
|
||||
def on_document_loaded(self):
|
||||
print("on_document_loaded called")
|
||||
@@ -191,16 +193,32 @@ class CommandorPage:
|
||||
except Exception as error:
|
||||
self.logger.error(error)
|
||||
|
||||
def getErrors(self):
|
||||
def get_errors(self):
|
||||
# send error result
|
||||
self.publish_message_to_queue(self.contact, PublishType.ERROR, self.page.url)
|
||||
try:
|
||||
items = self.page.query_selector("div.alert")
|
||||
if items:
|
||||
print(items.inner_html())
|
||||
erro_content = items.inner_html()
|
||||
print("错误:" + erro_content)
|
||||
self._handle_errors(erro_content)
|
||||
except Exception as ext:
|
||||
self.logger.error(ext)
|
||||
|
||||
def _handle_errors(self, erro_content: str):
|
||||
if DOUBLE_REQUEST_ERROR_MESSAGE in erro_content:
|
||||
# this email has been already used
|
||||
params.oracle_log_sender.send_double_data_error(self.contact)
|
||||
# close browser
|
||||
time.sleep(2)
|
||||
self.browser.close()
|
||||
elif TOO_MANY_REQUEST_ERROR_MESSAGE in erro_content:
|
||||
# this email has been already used
|
||||
params.oracle_log_sender.send_too_many_error(self.contact)
|
||||
# close browser
|
||||
time.sleep(2)
|
||||
self.browser.close()
|
||||
|
||||
def _set_email(self, email):
|
||||
time.sleep(get_random_wait_time())
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user