1

Copy of element via inspect:

</span></div></div></div><button class="primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root" label="Continue">Continue</button></div>

I am trying to press the continue button to go to the. next page

I have tried:

driver.find_element_by_xpath("//button[(@class='primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root')

Error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[(@class='primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root')]"}

also:

button = driver.find_element_by_class_name("primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root")

Resulting in again NoSuchElementException

Anyone have a tip ?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Djinn
  • 23
  • 2
  • Try this: `browser.find_element_by_xpath('//button[text()="Continue"]')` or `"//button[@class='primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root'][.='Continue']"` – DeepSea Nov 17 '20 at 20:09

2 Answers2

0

Don't take all name do this:

button = driver.find_element_by_class_name("LanguageSelectionForm_submitButton")

Verified if LanguageSelectionForm_submitButton is unique in document but if is not unique complete condition by using label="continue"

Thank you

unique
  • 128
  • 7
0

To identify the element with text as Continue you can use either of the following Locator Strategies:

  • Using css_selector:

    button = driver.find_element_by_css_selector("button.primary.LanguageSelectionForm_submitButton.SimpleButton_root.ButtonOverrides_root[label='Continue']")
    
  • Using xpath:

    button = driver.find_element_by_xpath("//button[@class='primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root' and text()='Continue']")
    

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

  • Using CSS_SELECTOR:

    button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.primary.LanguageSelectionForm_submitButton.SimpleButton_root.ButtonOverrides_root[label='Continue']")))
    
  • Using XPATH:

    button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='primary LanguageSelectionForm_submitButton SimpleButton_root ButtonOverrides_root' and text()='Continue']")))
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352