From 4f76007c7ad2e2df0807c19e57725cf4a16600d6 Mon Sep 17 00:00:00 2001 From: Heavenfighter Date: Tue, 5 Dec 2023 18:49:00 +0100 Subject: [PATCH] Fixed no element error when shipping type is pickup. --- kleinanzeigen_bot/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kleinanzeigen_bot/__init__.py b/kleinanzeigen_bot/__init__.py index 4c09753..5d101cf 100644 --- a/kleinanzeigen_bot/__init__.py +++ b/kleinanzeigen_bot/__init__.py @@ -531,11 +531,12 @@ class KleinanzeigenBot(SeleniumMixin): ############################# sell_directly = ad_cfg["sell_directly"] try: - if sell_directly and ad_cfg["shipping_type"] == "SHIPPING" and ad_cfg["shipping_options"] and price_type in {"FIXED", "NEGOTIABLE"}: - if not self.webdriver.find_element(By.ID, "radio-buy-now-yes").is_selected(): - self.web_click(By.XPATH, '//*[contains(@id, "radio-buy-now-yes")]') - elif not self.webdriver.find_element(By.ID, "radio-buy-now-no").is_selected(): - self.web_click(By.XPATH, '//*[contains(@id, "radio-buy-now-no")]') + if ad_cfg["shipping_type"] == "SHIPPING": + if sell_directly and ad_cfg["shipping_options"] and price_type in {"FIXED", "NEGOTIABLE"}: + if not self.webdriver.find_element(By.ID, "radio-buy-now-yes").is_selected(): + self.web_click(By.XPATH, '//*[contains(@id, "radio-buy-now-yes")]') + elif not self.webdriver.find_element(By.ID, "radio-buy-now-no").is_selected(): + self.web_click(By.XPATH, '//*[contains(@id, "radio-buy-now-no")]') except NoSuchElementException as ex: LOG.debug(ex, exc_info = True)