Skip to content

Commit 06a716f

Browse files
authored
fix: condition dialog selector for special attributes (#653)
## ℹ️ Description *Provide a concise summary of the changes introduced in this pull request.* - Link to the related issue(s): Issue #648 - Fix condition dialog selector that was failing to open and select condition values for special attributes during ad publishing. ## 📋 Changes Summary - Remove unused condition_mapping dictionary that was not needed - Fix dialog button selector to use aria-haspopup attribute instead of non-existent SelectionButton class - Fix radio button selection to use ID selector instead of data-testid approach - Simplify confirm button XPath selector for better reliability ### ⚙️ Type of Change Select the type(s) of change(s) included in this pull request: - [x] 🐞 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (adds new functionality without breaking existing usage) - [ ] 💥 Breaking change (changes that might break existing user setups, scripts, or configurations) ## ✅ Checklist Before requesting a review, confirm the following: - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 339d66e commit 06a716f

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/kleinanzeigen_bot/__init__.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -993,33 +993,22 @@ async def update_ads(self, ad_cfgs:list[tuple[str, Ad, dict[str, Any]]]) -> None
993993
LOG.info("############################################")
994994

995995
async def __set_condition(self, condition_value:str) -> None:
996-
condition_mapping = {
997-
"new_with_tag": "Neu mit Etikett",
998-
"new": "Neu",
999-
"like_new": "Sehr Gut",
1000-
"good": "Gut",
1001-
"ok": "Gut",
1002-
"alright": "In Ordnung",
1003-
"defect": "Defekt",
1004-
}
1005-
mapped_condition = condition_mapping.get(condition_value)
1006-
1007996
try:
1008997
# Open condition dialog
1009-
await self.web_click(By.XPATH, '//*[@id="j-post-listing-frontend-conditions"]//button[contains(@class, "SelectionButton")]')
998+
await self.web_click(By.XPATH, '//*[@id="j-post-listing-frontend-conditions"]//button[@aria-haspopup="true"]')
1010999
except TimeoutError:
10111000
LOG.debug("Unable to open condition dialog and select condition [%s]", condition_value, exc_info = True)
10121001
return
10131002

10141003
try:
10151004
# Click radio button
1016-
await self.web_click(By.CSS_SELECTOR, f'.SingleSelectionItem--Main input[type=radio][data-testid="{mapped_condition}"]')
1005+
await self.web_click(By.ID, f"radio-button-{condition_value}")
10171006
except TimeoutError:
10181007
LOG.debug("Unable to select condition [%s]", condition_value, exc_info = True)
10191008

10201009
try:
10211010
# Click accept button
1022-
await self.web_click(By.XPATH, '//*[contains(@id, "j-post-listing-frontend-conditions")]//dialog//button[contains(., "Bestätigen")]')
1011+
await self.web_click(By.XPATH, '//dialog//button[.//span[text()="Bestätigen"]]')
10231012
except TimeoutError as ex:
10241013
raise TimeoutError(_("Unable to close condition dialog!")) from ex
10251014

0 commit comments

Comments
 (0)