0
import sys
sys.path.append(r"/usr/local/lib/python2.7/dist-packages")
from selenium.webdriver.support.ui import WebDriverWait
import time  
import argparse
import sys
import itertools
from queue import Queue
import threading
import os

driver = webdriver.PhantomJS()
start_time = time.time()


try:
    driver.get("https://nucleus.niituniversity.in")
    emailFieldID = ".//*[@id='SchSel_txtUserName']"
    passFieldID = ".//*[@id='SchSel_txtPassword']"
    loginButtonXPath = ".//*[@id='SchSel_btnLogin']"
    emailFieldElement = WebDriverWait(driver, 10).until(lambda driver:      driver.find_element_by_xpath(emailFieldID))
    passFieldElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(passFieldID))
    loginButtonElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(loginButtonXPath))
    emailFieldElement.click()
    emailFieldElement.clear()
    emailFieldElement.send_keys("Username")
    passFieldElement.click()
    passFieldElement.clear()
    passFieldElement.send_keys("password")
    loginButtonElement.click()
    print("\n    Time Executed - " + str(time.time() - start_time)) 
    driver.save_screenshot('home.png')
    os._exit(1)
except: 
    driver.save_screenshot('error.png')
    driver.quit()

urllib.error.URLError: urlopen error [Errno 111] Connection refused

I have no idea why this is happening?I have tried turning off the firewall also but same error is raised.can anyone please help me sort this out?

anderson
  • 107
  • 1
  • 3
  • 11
  • can you provide further details on your error message? I suspect `driver.get("https:// ...` part can you test it with a http url instead https? – Bedi Egilmez Aug 20 '16 at 22:49
  • @BediEgilmez But the site I want to login is `https`.and i tried with `http` and there was timeout exception – anderson Aug 21 '16 at 05:55
  • I just wanted to make sure that problem caused by https. by default http and https uses different ports, this can be the reason of the problem. Once you make sure that this is the case, this following can be useful for you http://stackoverflow.com/questions/21001374/what-is-the-correct-way-to-feed-an-ssl-certificate-into-phantomjs/21020222 – Bedi Egilmez Aug 21 '16 at 06:01
  • Yes problem is caused by https – anderson Aug 21 '16 at 07:12

0 Answers0