Trying to use Selenium to select a country and state through a dropdown. Managed to get it to fill out a few forms like first name, last name etc. Getting an "selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="7f7a846e-ce26-49f2-b60d-202ac1a355f4"]"}
" error. Any suggestions as to what's causing this?
Code is as follows:
import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as Wait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import Select
driver = selenium.webdriver.Chrome(executable_path='/PATH')
def get_url(url):
driver.get(url)
driver.maximize_window()
def fill_data():
# Find the signup button
Wait(driver, 30).until(expected_conditions.presence_of_element_located
((By.ID, 'signup-button'))).click()
# Find the email name box
email_name = Wait(driver, 30).until(expected_conditions.visibility_of_element_located
((By.XPATH, "/html/body/onereg-app/div/onereg-form/div/div/form/section/"
"section[1]/onereg-alias-check/fieldset/onereg-progress-meter"
"/div[2] "
"/div[2]/div/pos-input[1]/input"))).send_keys('Test')
# Select gender
driver.find_element_by_xpath('/html/body/onereg-app/div/onereg-form/div/div/form/section'
'/section[2]/onereg-progress-meter/onereg-personal-info'
'/fieldset/div/div/onereg-radio-wrapper[2]/pos-input-radio/label/i').click()
# Fill out first and last name
Wait(driver, 30).until(expected_conditions.element_to_be_clickable
((By.XPATH, "//input[@data-test='first-name-input']"))).send_keys("Test")
Wait(driver, 30).until(expected_conditions.element_to_be_clickable
((By.XPATH, "//input[@data-test='last-name-input']"))).send_keys("Test")
# Select country and state
country = Select(driver.find_element_by_xpath('//*[@id="7f7a846e-ce26-49f2-b60d-202ac1a355f4"]'))
country.select_by_visible_text('Thailand')
state = Select(driver.find_element_by_xpath('//*[@id="409399e5-b61b-4b74-9ef7-7a511e29f339"]'))
state.select_by_visible_text('New York')
get_url('https://www.mail.com/')
fill_data()