1

I'm trying to click the "Launch Earth" button with this block of code.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Web
from selenium.webdriver.support import expected_conditions as EC
url = 'https://www.google.com/earth/'
driver = webdriver.chrome()
driver.get(url)
wait = WebDriverWait(driver, 10)
launchEarthButton = wait.until(EC.element_to_be_clickable((By.XPATH, '/html/body/header/div/nav[1]/ul[2]/li[2]/a/span/span' ))
launchEarthButton.click()

However, I get the error message below. What is wrong?

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-a51783f07755> in <module>
      2 
      3 from selenium.webdriver.common.by import By
----> 4 from selenium.webdriver.support.ui import Web
      5 from selenium.webdriver.support import expected_conditions as EC
      6 from webdriver_manager.chrome import ChromeDriverManager

ImportError: cannot import name 'Web' from 'selenium.webdriver.support.ui' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/support/ui.py)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Sean Taylor
  • 159
  • 5

1 Answers1

1

The is no module by the name Web within selenium.webdriver.support.ui.

However there are two(2) entries as follows:

from .select import Select  # noqa
from .wait import WebDriverWait  # noqa

Solution

In your code block as you are using WebDriverWait so you need to change Web to WebDriverWait, effectively:

from selenium.webdriver.support.ui import WebDriverWait
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352