mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
improve dropdown field handling
This commit is contained in:
@@ -617,6 +617,16 @@ class KleinanzeigenBot(SeleniumMixin):
|
||||
LOG.debug('Found %i special attributes', len(ad_cfg["special_attributes"]))
|
||||
for special_attribute_key, special_attribute_value in ad_cfg["special_attributes"].items():
|
||||
LOG.debug("Setting special attribute [%s] to [%s]...", special_attribute_key, special_attribute_value)
|
||||
try:
|
||||
# if the <select> element exists but is inside an invisible container, make the container visible
|
||||
select_container_xpath = f"//div[@class='l-row' and descendant::select[@id='{special_attribute_key}']]"
|
||||
select_container = self.web_find(By.XPATH, select_container_xpath)
|
||||
if not select_container.is_displayed():
|
||||
self.web_execute(f"document.evaluate(\"{select_container_xpath}\"," +
|
||||
" document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.style.display = 'block';")
|
||||
except BaseException:
|
||||
pass # nosec
|
||||
|
||||
try:
|
||||
self.web_select(By.XPATH, f"//select[@id='{special_attribute_key}']", special_attribute_value)
|
||||
except WebDriverException:
|
||||
|
||||
Reference in New Issue
Block a user