Getting browser not open error or session is not getting maintained for webdriver created by python module which is used in robot framework

HI,

Getting browser not open error or session is not getting maintained for webdriver created by python module which is used in robot framework as keyword

I am creating automation using robot framework and I was getting site can not be reached error when I was opening my website with below robot code
Call Method ${chrome_options} add_argument incognito
Call Method ${chrome_options} add_argument disable-dev-shm-usage
Call Method ${chrome_options} add_argument no-sandbox
Create_Webdriver Chrome chrome_options=${chrome options}
Go To https://mysite.net

image

So I wrote python code to create instance of undetected-chrome driver and imported that module in robot framework like below then I am able to access site but for next click action I am getting error like, No Browser is open

import undetected_chromedriver as uc
import time
def create_undetected_webdriver():
try:
    # options = webdriver.ChromeOptions()
    # # options=undetected_chromedriver.options.ChromeOptions()
    # options.add_argument("--start-maximized")
    # options.add_argument("--disable-blink-features=AutomationControlled")
    # options.add_experimental_option("prefs", {"credentials_enable_service": False,
    #                                              "profile.password_manager_enabled": False})
    # options.add_experimental_option("prefs", prefs)
    # options.add_experimental_option('excludeSwitches', ['enable-logging', "enable-automation"])
    # options.add_experimental_option("useAutomationExtension", False)
    driver = uc.Chrome()
    # Setting Driver Implicit Time out for An Element
    driver.implicitly_wait(10)
    # Maximize the window
    driver.maximize_window()
    driver.get('https://mysite.net')
    print("Opened Site")
except Exception as err:
    print('Exception occured while initializing webdriver {str(err)}')
return driver

Then I have used this custom python method in robot framework as below and I am able to access mysite but not able perform further action, it is giving an error - No browser open

 create_undetected_webdriver
Click Element Using Locator    ${NY_login_sign_in_btn_xpath}
Log To Console    Maximizing browser window
maximize browser window

Can you please , why it is not maintaining session of driver created by python module in robot framework
Thanks in advance