I want to click on the list
but they will give me time out error
these is the page link
This is code:
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 time import sleep
PATH="C:\Program Files (x86)\chromedriver.exe"
url='https://www.s-ge.com/de/members-map'
driver =webdriver.Chrome(PATH)
driver.get(url)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#m-view-tabs__button is-activ"))).click()
CodePudding user response:
Could you try to use this XPath locator instead?
//button[contains(@data-target-tab, 'list')]
Either the locator is not correct, or the element is not clickable. In case the element is not clickable, try to use js click.
element = driver.find_element_by_xpath("//button[contains(@data-target-tab, 'list')]")
def js_click(self, element):
driver.execute_script("arguments[0].click();", element)
CodePudding user response:
First of all, you have to accept cookies and as list element isn't clickable with related to boolean that's why you need to execute javascript to click. Now your code is working fine.Please just run the code.
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = 'https://www.s-ge.com/de/members-map'
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get(url)
time.sleep(10)
wait = WebDriverWait(driver, 20)
wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@]/a'))).click()
button=driver.find_element_by_xpath("//button[contains(@data-target-tab, 'list')]")
driver.execute_script("arguments[0].click();", button)