My Code:
#Open Website
profile_path = r'C:\Users\XXX\AppData\Local\Mozilla\Firefox\Profiles\ndefault-release'
options = Options()
options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'
options.set_preference('profile', profile_path)
options.add_argument("--no-sandbox")
service = Service(r'C:\Users\XXX\geckodriver.exe')
driver = Firefox(service=service, options=options)
# declaration of variables
name = "x"
suffix = "x"
start_number = 1
end_number = 1000
for i in range(start_number, end_number):
driver.get('https://www.bauhaus.info/')
time.sleep(5)
driver.implicitly_wait(10)
driver.find_element(by=By.XPATH, value=f"/div/div/div/div/div[2]/div/div[2]/div/div/div/button").click()
After executing i get following error:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /div/div/div/div/div[2]/div/div[2]/div/div/div/button Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.jsm:12:1 WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5 element.find/</<@chrome://remote/content/marionette/element.js:291:16 PS C:\Users\Martin\Desktop\Selenium - Login2me>
I added this "driver.implicitly_wait(10)" so the element is there and also it seems that this cookie windows is not inside an addition iframe. cant figure out why i get this error.