0

I'm trying to use Selenium to select the 2nd option (with the text "24 words") from the drop-down menu on this page: https://www.myetherwallet.com/wallet/access/software?type=mnemonic

I was able to click on the drop-down menu to display the 2 options using this piece of code:

drop_down_menu = driver.find_element(By.XPATH, '//div[@class="v-select__slot"]')
drop_down_menu.click()

However I was not able to select the 2nd option (or any options). I could not use Selenium Select class because the drop-down menu element is not of Select type element. I tried the below 2 pieces of code without any success:

select_24_words = WebDriverWait(driver, 10).until(EC.text_to_be_present_in_element_value(
            (By.CSS_SELECTOR, 'div#list-item-252-1.v-list-item.v-list-item--link.theme--light'),'24'))
select_24_words.click()

and

select_24_words = driver.find_element(By.XPATH, '//div[@id="list-item-252-1"]')
select_24_words.click()

Can anyone help?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Avn
  • 31
  • 1

3 Answers3

0

Used element_to_be_clickable condition for the xpath - //div[text()='24 words'] and was able to click on 24 word option.

Try like below once.

driver.get("https://www.myetherwallet.com/wallet/access/software?type=mnemonic")

wait = WebDriverWait(driver,30)

wait.until(EC.element_to_be_clickable((By.CLASS_NAME,"v-select__selections"))).click()

wait.until(EC.element_to_be_clickable((By.XPATH,"//div[text()='24 words']"))).click()
pmadhu
  • 3,373
  • 2
  • 11
  • 23
0

The drop-down menu isn't a conventional element so you can't use Select class.

To select the 2nd option (with the text "24 words") from the drop-down menu you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using XPATH:

    driver.get("https://www.myetherwallet.com/wallet/access/software?type=mnemonic")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='v-select__selections']"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='v-list-item__title' and text()='24 words']"))).click()
    
  • Browser Snapshot:

myetherwallet

  • 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
0

You need to click on the drop-down bar. Then default option.

Then you can click on second option.

All you need is a Explicit Waits.

driver = webdriver.Chrome(driver_path)
driver.maximize_window()
driver.get("https://www.myetherwallet.com/wallet/access/software?type=mnemonic")
default_option = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.v-select__selection--comma")))
default_option.click()

second_option = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[text()='24 words']/ancestor::div[contains(@id,'item')]")))
second_option.click()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
cruisepandey
  • 28,520
  • 6
  • 20
  • 38