Skip to content

Commit

Permalink
Merge pull request #16 from kowshika-n/master
Browse files Browse the repository at this point in the history
Minor updates and cleanup
  • Loading branch information
navchandar authored Jul 29, 2021
2 parents 5977978 + 8db57c0 commit 5649c3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
14 changes: 9 additions & 5 deletions naukri.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import re
import os
import io
import sys
import time
import logging
Expand All @@ -14,7 +15,8 @@
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from PyPDF2 import PdfFileReader, PdfFileWriter
import random, string, io
from string import ascii_uppercase, digits
from random import choice, randint
from datetime import datetime
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
Expand Down Expand Up @@ -141,6 +143,10 @@ def tearDown(driver):
pass


def randomText():
return "".join(choice(ascii_uppercase + digits) for _ in range(randint(1, 5)))


def LoadNaukri(headless):
"""Open Chrome to load Naukri.com"""
options = webdriver.ChromeOptions()
Expand Down Expand Up @@ -176,6 +182,7 @@ def naukriLogin(headless = False):
if "naukri" in driver.title.lower():
log_msg("Website Loaded Successfully.")

emailFieldElement = None
if is_element_present(driver, By.ID, "emailTxt"):
emailFieldElement = GetElement(driver, "emailTxt", locator="ID")
time.sleep(1)
Expand Down Expand Up @@ -288,10 +295,7 @@ def UpdateProfile(driver):
def UpdateResume():
try:
# random text with with random location and size
txt = "".join(
random.choice(string.ascii_uppercase + string.digits)
for _ in range(random.randint(1, 10))
)
txt = randomText()
xloc = random.randint(700, 1000) # this ensures that text is 'out of page'
fsize = random.randint(1, 10)

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
reportlab==3.5.48
webdriver_manager==3.2.2
selenium==3.141.0
webdriver-manager==3.1.0
PyPDF2==1.26.0
reportlab==3.5.44
7 changes: 4 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import unittest
import naukri


class Test(unittest.TestCase):
def test_naukri(self):
(status, driver) = naukri.naukriLogin(headless = True)
(status, driver) = naukri.naukriLogin(headless=True)
naukri.tearDown(driver)
self.assertFalse(status)


if __name__ == '__main__':
unittest.main()
if __name__ == "__main__":
unittest.main()

0 comments on commit 5649c3a

Please sign in to comment.