Hi, I have a scenario where I use a custom keyword.
I can run the scenarios locally and its always working.
The problem is when I try to run on BrowserStack, when its time to run the keyword, I got the error message No keyword with name ‘Get Confirmation Code’ found."
/// THE KEYWORD
from imap_tools import MailBox
import re
import time
from robot.api.deco import keyword
@keyword
def get_confirmation_code():
username = “xxxxxxx”
password = “xxxxxxxx”
imap_server = “imap.fastmail.com”
pattern = r'\b\d{6}\b'
attempts = 12
delay = 15
for attempt in range(attempts):
with MailBox(imap_server).login(username, password, "Inbox") as mb:
for msg in mb.fetch(criteria='UNSEEN', limit=5, reverse=True, mark_seen=True):
if msg.from_ == "xxxxxxx":
match = re.search(pattern, msg.text)
if match:
return match.group()
print(f"No new emails found, attempt {attempt + 1}/{attempts}. Waiting for {delay} seconds.")
time.sleep(delay) # Wait before the next attempt
return None
///THE STEP
I login into the app
Click Text Start now
Input Text Into Current Element ${userEmail}
Click Element xpath=${loginPageSendEmailButton}
Sleep 5
${code}= Run Keyword Get Confirmation Code. <-------
/// How Im importing it
*** Settings ***
Library AppiumLibrary
Library ${CURDIR}/…/helper/email/emailReader.py <----
Keep in mind that it is working fine on appium local, the problem is when I try to use BrowserStack