Selenium just opens Chrome and stops the program using ChromeDriverManager

110 views Asked by At

My problem is that I want to execute the whole code, but it just opens Chrome and stops the program. What could be the reason for this? I installed every package needed such as the chromedriver into the same directory as the scriptfile.[![enter image description here][1]][1]

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 import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time


driver = webdriver.Chrome(ChromeDriverManager().install())


time.sleep(5)

# Öffne die angegebene URL
driver.get("https://www.nike.com/de/launch/t/air-force-1-07-fresh")

# Warte bis die Seite geladen ist
wait = WebDriverWait(driver, 10)
wait.until(EC.presence_of_element_located((By.CLASS_NAME, "size-grid-button")))

# Scrolle nach unten
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

# Warte 3 Sekunden
import time
time.sleep(3)

# Wähle Größe 9 aus
size_button = driver.find_element_by_xpath('//*\[@class="size-grid-button" and contains(text(),"9")\]')
size_button.click()

# Drücke den Kauf-Knopf
buy_button = driver.find_element_by_class_name("buying-tools-cta-button")
buy_button.click()

# Gib die Nachricht "Zugriff erfolgt" zurück
print("Zugriff erfolgt")]

Snapshot:

snapshot

1

There are 1 answers

1
undetected Selenium On

Incase you are using you need to pass the argument:

ChromeDriverManager().install()

along with the service keyword as follows:

from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.nike.com/de/launch/t/air-force-1-07-fresh")