From 668135d669b038faace287d20a87bd73799ff091 Mon Sep 17 00:00:00 2001 From: feder-cr Date: Thu, 22 Aug 2024 19:33:25 +0100 Subject: [PATCH] radio fixed --- linkedIn_easy_applier.py | 11 +++++++---- linkedIn_job_manager.py | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/linkedIn_easy_applier.py b/linkedIn_easy_applier.py index 759e506..27bee3a 100644 --- a/linkedIn_easy_applier.py +++ b/linkedIn_easy_applier.py @@ -215,7 +215,8 @@ class LinkedInEasyApplier: return False def _find_and_handle_radio_question(self, section: WebElement) -> bool: - radios = section.find_elements(By.CLASS_NAME, 'fb-text-selectable__option') + question = section.find_element(By.CLASS_NAME, 'jobs-easy-apply-form-element') + radios = question.find_elements(By.CLASS_NAME, 'fb-text-selectable__option') if radios: question_text = section.text.lower() options = [radio.text.lower() for radio in radios] @@ -224,6 +225,7 @@ class LinkedInEasyApplier: return True return False + def _find_and_handle_textbox_question(self, section: WebElement) -> bool: text_fields = section.find_elements(By.TAG_NAME, 'input') + section.find_elements(By.TAG_NAME, 'textarea') if text_fields: @@ -271,9 +273,10 @@ class LinkedInEasyApplier: def _select_radio(self, radios: List[WebElement], answer: str) -> None: for radio in radios: - if radio.text.lower() == answer.lower(): - radio.click() - break + if answer in radio.text.lower(): + radio.find_element(By.TAG_NAME, 'label').click() + return + radios[-1].find_element(By.TAG_NAME, 'label').click() def _select_dropdown_option(self, element: WebElement, text: str) -> None: select = Select(element) diff --git a/linkedIn_job_manager.py b/linkedIn_job_manager.py index 2a0bee9..45a8a52 100644 --- a/linkedIn_job_manager.py +++ b/linkedIn_job_manager.py @@ -145,16 +145,16 @@ class LinkedInJobManager: def write_to_file(self, job, file_name): + pdf_path = Path(job.pdf_path).as_uri() data = { "company": job.company, "job_title": job.title, "link": job.link, "job_location": job.location, - "pdf_path": job.pdf_path + "pdf_path": pdf_path } file_path = self.output_file_directory / f"{file_name}.json" if not file_path.exists(): - job.pdf_path = file_path.as_posix() with open(file_path, 'w', encoding='utf-8') as f: json.dump([data], f, indent=4) else: