jnhyperion / HyperRobotFrameworkPlugin

Robot Framework plugin for PyCharm.
31 stars 5 forks source link

The browser window will be closed when the case runs finished #58

Closed DANIKE closed 1 year ago

DANIKE commented 1 year ago

Hi,I run the test case in pycharm and the browser window will be closed when the case runs finished. I have tried add options "add_experimental_option("detach", True)" when open the browser but it didn't work. There is no setdown or close browser sentense in my case. I want to know if you have the problem and glad to hear from you, thanks.

jnhyperion commented 1 year ago

This is not related to plugin.

About your case: when you start to run a test, your test process will start a web driver and browser subprocess. after you test is finished, your test process will exit and all its subprocess will exit too. if you want to prevent the web browser closing, you can add some sleep after your test tear down.

Or you can manually start a web driver process firstly, then attach to the web driver in your test, using something like:

from selenium import webdriver

# Provide the URL of the WebDriver server (e.g., chromedriver)
webdriver_url = "http://localhost:9515"  # Change this to your WebDriver server URL

# Provide the session ID of the existing browser session
existing_session_id = "your_existing_session_id"

# Attach to the existing browser session
driver = webdriver.Remote(command_executor=webdriver_url, desired_capabilities={})
driver.session_id = existing_session_id

# Now you can interact with the browser using the attached driver
driver.get("https://www.example.com")
print(driver.title)

# Remember to quit the driver when you're done
driver.quit()