0
votes

I'm trying to make selenium close a tab after it spots a text saying 'Universal Script'

Right now I have this but it doesn't seem to work

is_universal = None
if title == "Universal Script":
    is_universal = True
if is_universal == None:
   ''rest of the code''
driver.close()

Code for the text

title = driver.find_element(By.XPATH, '/html/body/div[1]/div/div/div[1]/main/div[2]/div[2]/div[1]/span').text
Do you mean that the tab stays open? - Dan Getz
@DanGetz no it closes I have a code that takes many links and when it closes it just goes to the next link - Lubaba Ell
OK, so what does "it doesn't seem to work" mean, then? - Dan Getz
@DanGetz it doesn't close the driver, just keeps going through the rest of the code - Lubaba Ell