Skip to content

Commit

Permalink
Update naukri.py
Browse files Browse the repository at this point in the history
Updated for Uploading resume and saving. You can change the path in the code.
  • Loading branch information
navchandar committed Apr 28, 2016
1 parent 141688f commit a71871d
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions naukri.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#Naukri Daily update
import time, re
import unittest
from selenium import webdriver
from selenium.webdriver.chrome.options import Option
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest

class Login(unittest.TestCase):
def setUp(self):
Expand All @@ -27,7 +29,8 @@ def test_Login(self):
editXpath = "//*[@id='rPanel']/div/div[1]/div[2]/h1/a"
mobName = "mobile"
saveXpath = ".//*[@id='rPanel']/div/div/form/div[5]/div/button"

uploadNew = "uploadLink"
attachXpath = '//*[@id="attachCV"]'
emailFieldElement = WebDriverWait(driver, 5).until(lambda driver: driver.find_element_by_id(emailID))
passFieldElement = WebDriverWait(driver, 5).until(lambda driver: driver.find_element_by_id(passID))
loginButtonElement = WebDriverWait(driver, 5).until(lambda driver: driver.find_element_by_name(loginbuttonName))
Expand All @@ -53,9 +56,51 @@ def test_Login(self):
saveFieldElement = WebDriverWait(driver, 4).until(lambda driver: driver.find_element_by_xpath(saveXpath))
saveFieldElement.send_keys(Keys.ENTER);
self.driver.implicitly_wait(3)
self.driver.find_element_by_id("uploadLink").click()
for i in range(60):
try:
if self.is_element_present(By.ID, "attachCV"): break
except: pass
time.sleep(1)
else: self.fail("time out")
driver.find_element_by_id("attachCV").clear()
time.sleep(1)
driver.find_element_by_id("attachCV").send_keys(""C:\\Resume.pdf") #Update the Resume path
time.sleep(2)
driver.find_element_by_xpath("//button[@type='button']").click()
time.sleep(1)
self.driver.implicitly_wait(5)
self.assertTrue(self.is_element_present(By.ID, "confirmMessage"))

self.driver.implicitly_wait(3)

def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException: return False
return True

def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException: return False
return True

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True

def tearDown(self):
self.driver.close()
self.driver.quit()


if __name__ == '__main__':
unittest.main()
sys.exit
exit

0 comments on commit a71871d

Please sign in to comment.