Skip to content

Commit

Permalink
Leaving cover letter uploading locator in to be fixed later.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCredible committed Jul 24, 2020
1 parent d98b3c0 commit 8f287e3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions easyapplybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,18 @@ def is_present(button_locator):
try:

time.sleep(random.uniform(2.2, 4.3))
log.info("Attempting to send resume")
log.info("Attempting to apply")
#TODO These locators are not future proof. These labels could easily change.
# Ideally we would search for contained text;
# was unable to get it to work using XPATH and searching for contained text
upload_locator = (By.CSS_SELECTOR, "input[name='file']")
upload_locator = (By.CSS_SELECTOR, "label[aria-label='DOC, DOCX, PDF formats only (2 MB).']")
next_locator = (By.CSS_SELECTOR, "button[aria-label='Continue to next step']")
review_locator = (By.CSS_SELECTOR, "button[aria-label='Review your application']")
submit_locator = (By.CSS_SELECTOR, "button[aria-label='Submit application']")
submit_application_locator = (By.CSS_SELECTOR, "button[aria-label='Submit application']")
error_locator = (By.CSS_SELECTOR, "p[data-test-form-element-error-message='true']")
cover_letter = (By.CSS_SELECTOR, "input[name='file']")


question_locator = (By.XPATH, ".//div[@class='jobs-easy-apply-form-section__grouping']")
yes_locator = (By.XPATH, ".//input[@value='Yes']")
no_locator = (By.XPATH, ".//input[@value='No']")
Expand All @@ -320,14 +319,14 @@ def is_present(button_locator):
while not submitted:
button = None

# Upload Cover Letter if possible
# Upload if possible

#TODO Should check if there is already a resume that is saved from the last time the application was attempted.
# If so, then remove and re upload it in case there is new version.
if is_present(upload_locator):

input_buttons = self.browser.find_elements(upload_locator[0],
upload_locator[1])
log.info("Resume upload option available. Attempting to upload.")
input_buttons = self.browser.find_elements(cover_letter[0],
cover_letter[1])
for input_button in input_buttons:
parent = input_button.find_element(By.XPATH, "..")
sibling = parent.find_element(By.XPATH, "preceding-sibling::*")
Expand All @@ -336,9 +335,6 @@ def is_present(button_locator):
if key in sibling.text or key in grandparent.text:
input_button.send_keys(self.uploads[key])


#input_button[0].send_keys(self.cover_letter_loctn)

for i, button_locator in enumerate(
[upload_locator, next_locator, review_locator, submit_locator, submit_application_locator]):

Expand Down

0 comments on commit 8f287e3

Please sign in to comment.