2

I am looking for a way to click on the svg cross to close overlaying welcome window. I managed to go through login and authorization but this cross is getting me crazy.

Code trials:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CLASS_NAME, "jss109"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//svg[@class='jss109']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'svg[aria-hidden="True"]')).click()
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CLASS_NAME, "JSS109"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='jss109']/*[name()='svg']")))

Error massage: TimeoutException: Message:

Snapshot of the HTML:

enter image description here

Another snapshot of the HTML:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Paulina
  • 83
  • 6

1 Answers1

1

To click on the X icon you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "h2 svg.jss109[viewBox]"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//h2[.//span[starts-with(., 'Welcome to new')]]//*[name()='svg' and @class][@viewBox]"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Thank you so much!! I tried CSS_SELECTOR and it works!:) Can you share any description why to use class above(like here-h2)? – Paulina Feb 05 '23 at 22:07
  • 1
    The `` is indeed within the `

    `, so it's always a better idea to construct a precise locator. Now with _xpath_ I was easily able to identify the required `

    ` with respect to the text _`Welcome to new`_, where as for the _CSS_SELECTOR_ I took a chance with the decendant `` classname _`jss109`_ which initially looked dynamic to me. Still I took a chance.

    – undetected Selenium Feb 05 '23 at 22:11
  • 1
    I get it - i think. Thank you once again! – Paulina Feb 05 '23 at 22:14