Cannot select items in a particular drop down menu
I am doing some web scraping using Selenium and Beautiful Soup in python. This is the website I am scraping data from.
from bs4 import BeautifulSoup as soup
from selenium import webdriver
from selenium.webdriver.support.ui import Select
driver = webdriver.Firefox()
driver.get("http://www.forex.pk/foreign-exchange-rate.htm")
forex_soup = soup(driver.page_source,"html.parser")
Selecting 10 decimal places from the drop down menu works:
Select(driver.find_element_by_id('decimals')).select_by_value("10")
Clicking the submit button also works:
driver.find_element_by_id('btnShow').click()
However, I can't seem to select the base currency. What am I doing wrong? I have tried the following:
Select(driver.find_element_by_id('currid')).select_by_index(3)
and
Select(driver.find_element_by_id('currid')).select_by_value("3")
Also note that while there are 78 currencies, the following returns 9. I guess only the currencies above the "------" item are being included. How do I get all the options?
len(Select(driver.find_element_by_id('currid')).select_by_index(n).options)
Posted Oct 28, 2017, 7:52 AM UTC
13