IDLE doesn't terminate my selenium broswer despite driver.close and driver.quit

Viewed 55

I've written this script which works exactly how I want it to however while using IDLE, the selenium proxy browser does not terminate. I haven't experienced this issue while using Atom IDE, it properly terminates in Atom. Why does it work in Atom and not IDLE?

Heres the script:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select



def sbtgt():
    sbtgt_url = 'http://www.1line.williams.com/ebbCode/OACQueryRequest.jsp?BUID=80&type=OAC'
    sbtgt_driver = webdriver.Chome(filepath) 
    sbtgt_driver.get(sbtgt_url) 
    sbtgt_driver.find_element_by_css_selector("body > form > p > input[type=submit]").click()
    WebDriverWait(sbtgt_driver, 30).until(EC.number_of_windows_to_be(2))
    sbtgt_report = sbtgt_driver.window_handles[1]
    sbtgt_driver.switch_to_window(sbtgt_report)
    sbtgt_lighthouse = sbtgt_driver.find_element_by_xpath("/html/body/form/table/tbody/tr[2]/td/div/table[3]/tbody/tr[223]/td[9]").get_property("textContent")
    return sbtgt_lighthouse
    print(sbtgt_lighthouse)
    sbtgt_driver.close()
    sbtgt_driver.quit() 
    sbtgt() 

Everything executes as desired EXCEPT the driver.close and driver.quit... on Atom IDE the proxy browser terminates and closes. On IDLE, it stays open even after the script is finished running. For automation purposes this is becoming a hassle and I am not sure why it will not close.

Thank you for the help

1 Answers

it looks like you are calling sbtgt_driver.close() and sbtgt_driver.quit() after the return statement so they shouldn't be executing. Make sure to call those then return.

Related