(Nov-21-2021, 03:44 PM)gw1500se Wrote: According to the documentation, that should work. I have not been able to find anything useful about this error. The only thing I found was a suggestion to use select_by_visible_text which in my case is going to be a pain as I would have to develop it.
There is own import for this,then most use
Select
call to get
.select_by_visible_text()
or
.select_by_value()
to work.
from selenium.webdriver.support.ui import Select
To give a example whole step-1 finish.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from bs4 import BeautifulSoup
import time
#--| Setup
options = Options()
#options.add_argument("--headless")
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
url = "https://www.donotcall.gov/report.html"
browser.get(url)
time.sleep(3)
button_continue = browser.find_elements_by_css_selector('#MainContinueButton')
button_continue[0].click()
# Continue with fill all the form data
time.sleep(3)
phone = browser.find_elements_by_css_selector('#PhoneTextBox')
phone[0].send_keys("2514455669")
date = browser.find_elements_by_css_selector('#DateOfCallTextBox')
date[0].click()
date_1 = browser.find_elements_by_css_selector('td.ui-datepicker-days-cell-over.ui-datepicker-today > a')
date_1[0].click()
# Time of call
time.sleep(3)
select_time = Select(browser.find_element_by_id('TimeOfCallDropDownList'))
select_time.select_by_visible_text('03:00 AM')
select_min = Select(browser.find_element_by_id('ddlMinutes'))
select_min.select_by_visible_text('02')
time.sleep(3)
# Record, receive and about
time.sleep(3)
record = browser.find_elements_by_css_selector('#PrerecordMessageYESRadioButton')
record[0].click()
receive = browser.find_elements_by_css_selector('#PhoneCallRadioButton')
receive[0].click()
select_about = Select(browser.find_element_by_id('ddlSubjectMatter'))
select_about.select_by_visible_text('Unknown')
# Next step
time.sleep(3)
continue_next = browser.find_elements_by_css_selector('#StepOneContinueButton')
continue_next[0].click()