I iterate on a google form survey and try to put some content (which I try to make look like a quote just in case). However some fields are ages and do not allow to be more than 99 years old like this:
<input type="text" class="quantumWizTextinputPaperinputInput exportInput" jsname="YPqjbf" autocomplete="off" tabindex="0" aria-label="Age" aria-describedby="i.desc.504994172 i.err.504994172" name="entry.128750970" value="" min="18" max="99" required="" dir="auto" data-initial-dir="auto" data-initial-value="10102015" badinput="false" aria-invalid="true">
So I added a condition in my code to try to see if there is a 'max' attribute on the elements I have to write on:
content_areas = driver.find_elements_by_class_name(
"quantumWizTextinputSimpleinputInput.exportInput"
)
for content_area in content_areas:
if content_area.get_attribute("max") exists:
max = content_area.get_attribute("max")
content_area.send_keys(max)
else:
content_area.send_keys("10102015")
But it doesn't work:
max:
Traceback (most recent call last):
File "questions_scraper_michael.py", line 151, in <module>
result = extract(driver, df, column)
File "questions_scraper_michael.py", line 70, in extract
"freebirdFormviewerViewNumberedItemContainer"
File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 580, in find_elements_
by_class_name
return self.find_elements(by=By.CLASS_NAME, value=name)
File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 1007, in find_elements
'value': value})['value'] or []
File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\antoi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\errorhandler.py", line 241, in check_respo
nse
raise exception_class(message, screen, stacktrace, alert_text)
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: {Alert text :
Message: unexpected alert open: {Alert text : }
(Session info: chrome=83.0.4103.61)