Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Selenium python code quits the webpage after execution

Selenium code quits the webpage page after executing, although I added the line "driver.quit()" and it quits after loading the webpage.

Note: The browser is Microsoft Edge


    from selenium import webdriver
    from selenium.webdriver.common.by import By
    driver = webdriver.Edge()
    driver.get("https://www.youtube.com/?app")
    driver.set_window_size(1285, 824)
    driver.quit()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The driver.quit() method is used to close the entire browser session, and it should be used at the end of your script when you are done with the browser.

Try like this

from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Edge()
driver.get("https://www.youtube.com/?app")
driver.set_window_size(1285, 824)

# Add some interactions or operations on the page
# For example, click a button or wait for a few seconds
time.sleep(5)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading