How can I click the button and move to next page using selenium?

I am not able to click the button using selenium and move to the next page. I have tried the following commands:


I have added a screenshot of the html.

enter image description here

What am I doing wrong?


To click on the element with text as Production you can use either of the following Locator Strategies:

  • Using css_selector:

    driver.find_element(By.CSS_SELECTOR, "button.nav-option.nav-option--main > div.section-title").click()
  • Using xpath:

    driver.find_element(By.XPATH, "//button[@class='nav-option nav-option--main']/div[@class='section-title']//div[text()='Production']").click()

Ideally to click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:


    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.nav-option.nav-option--main > div.section-title"))).click()
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='nav-option nav-option--main']/div[@class='section-title']//div[text()='Production']"))).click()
  • Note: You have to add the following imports :

    from import WebDriverWait
    from import By
    from import expected_conditions as EC

Source: stackoverflow