I can click the "AKZEPTIEREN" button using XPATH like this:
WebDriverWait(driver, 15).until(expected_conditions.element_to_be_clickable((By.XPATH, '/html/body/div[4]/div/button[2]'))).click()
To make it more dynamic I want to use a class, so this would be:
WebDriverWait(driver, 15).until(expected_conditions.element_to_be_clickable((By.CLASS_NAME, 'primary.accept.no-pop-execute'))).click()
But the class "primary accept no-pop-execute" is twice on the site. So what can I do to choose the first one?
CodePudding user response:
You can try the below code using xpath expression that will select a single element and click on it because click()
method requires a single selection:
WebDriverWait(driver, 15).until(expected_conditions.element_to_be_clickable((By.XPATH, '//*[@ and contains(., "Akzeptieren")]'))).click()