The problem: trying to click on a drop-down within an iframe using Chrome driver and Selenium with Python.
Hi all. A user kindly helped me with a newbie query yesterday. I was unable to click on a link within a url and this was because I had to switch into an iframe. This part of the code now works and I navigate to a drop-down menu for which I wish to make a selection.
I've tried accessing this element through amending my code but receive the traceback that it is unable to locate the element. I am trying to change the value of the drop-down to 'Aldershot' using Select, finding the element by name and visible text. Any advice greatly appreciated.
#setup
from selenium import webdriver
from selenium.webdriver.support.select import Select
#utilise chrome driver to open specified webpage
driver = webdriver.Chrome("/Users/philthomas/Desktop/web/chromedriver")
driver.maximize_window()
driver.get("http:enfa.co.uk")
#switch to specific iframe and click on 'clubs' button on left hand menu
driver.switch_to.frame(2);
ClubsLink=WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,
"//span[contains(text(),'Clubs')]")))
ClubsLink.click()
#find drop-down menu and choose 'Aldershot'
select_box = Select(driver.find_element_by_name("team"))
select_box.select_by_visible_text("Aldershot")
Traceback:
HTML:


