Merge remote-tracking branch 'origin/v3' into v3

This commit is contained in:
queukat 2024-09-08 17:45:24 +03:00
commit ad85b9587f

View file

@ -166,7 +166,8 @@ class LinkedInEasyApplier:
logger.debug(f"Attempting search using {method['description']}") logger.debug(f"Attempting search using {method['description']}")
if method.get('find_elements'): if method.get('find_elements'):
# Поиск всех кнопок "Easy Apply"
buttons = self.driver.find_elements(By.XPATH, method['xpath']) buttons = self.driver.find_elements(By.XPATH, method['xpath'])
if buttons: if buttons:
for index, button in enumerate(buttons): for index, button in enumerate(buttons):
@ -738,10 +739,8 @@ class LinkedInEasyApplier:
def _find_and_handle_dropdown_question(self, section: WebElement) -> bool: def _find_and_handle_dropdown_question(self, section: WebElement) -> bool:
try: try:
# Попытка найти элемент с вопросом через класс
question = section.find_element(By.CLASS_NAME, 'jobs-easy-apply-form-element') question = section.find_element(By.CLASS_NAME, 'jobs-easy-apply-form-element')
# Если не удалось найти элемент с классом, пробуем искать по атрибуту 'data-test-text-entity-list-form-select'
dropdowns = question.find_elements(By.TAG_NAME, 'select') dropdowns = question.find_elements(By.TAG_NAME, 'select')
if not dropdowns: if not dropdowns:
dropdowns = section.find_elements(By.CSS_SELECTOR, '[data-test-text-entity-list-form-select]') dropdowns = section.find_elements(By.CSS_SELECTOR, '[data-test-text-entity-list-form-select]')
@ -753,14 +752,13 @@ class LinkedInEasyApplier:
logger.debug(f"Dropdown options found: {options}") logger.debug(f"Dropdown options found: {options}")
# Извлечение текста вопроса
question_text = question.find_element(By.TAG_NAME, 'label').text.lower() question_text = question.find_element(By.TAG_NAME, 'label').text.lower()
logger.debug(f"Processing dropdown or combobox question: {question_text}") logger.debug(f"Processing dropdown or combobox question: {question_text}")
current_selection = select.first_selected_option.text current_selection = select.first_selected_option.text
logger.debug(f"Current selection: {current_selection}") logger.debug(f"Current selection: {current_selection}")
# Найдем существующий ответ в сохраненных данных
existing_answer = None existing_answer = None
for item in self.all_data: for item in self.all_data:
if self._sanitize_text(question_text) in item['question'] and item['type'] == 'dropdown': if self._sanitize_text(question_text) in item['question'] and item['type'] == 'dropdown':