inital commit
This commit is contained in:
76
scrapper/webistes/identity_iq_old/user_validation.py
Normal file
76
scrapper/webistes/identity_iq_old/user_validation.py
Normal file
@@ -0,0 +1,76 @@
|
||||
from selenium import webdriver
|
||||
from selenium.common.exceptions import TimeoutException, NoSuchElementException
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as ec
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
|
||||
def user_validation(email, password, ssn):
|
||||
try:
|
||||
url = "https://member.identityiq.com/"
|
||||
|
||||
chrome_path = "/usr/lib/chromium-browser/chromedriver"
|
||||
#chrome_local_path = "D:\\scrapper\\chromedriver_win32\\chromedriver.exe"
|
||||
chrome_local_path = "D:\\scrapper\\chromedriver_win64\\chromedriver.exe"
|
||||
|
||||
option = webdriver.ChromeOptions()
|
||||
option.add_argument('--headless')
|
||||
option.add_argument('--no-sandbox')
|
||||
option.add_argument('--disable-dev-sh-usage')
|
||||
#driver = webdriver.Chrome(chrome_path,options=option)
|
||||
driver = webdriver.Chrome(chrome_local_path,options=option)
|
||||
|
||||
#phantomjs_server_path = "/usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs"
|
||||
phantomjs_local_path = "D:\\scrapper\\phantomjs-2.1.1-windows\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe"
|
||||
|
||||
#driver = webdriver.PhantomJS(executable_path= phantomjs_server_path,service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
|
||||
#driver = webdriver.PhantomJS(executable_path= phantomjs_local_path,service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
|
||||
|
||||
|
||||
driver.get(url + 'login.aspx')
|
||||
driver.find_element_by_name('txtUsername').send_keys(email)
|
||||
driver.find_element_by_name('txtPassword').send_keys(password)
|
||||
driver.find_element_by_id("imgBtnLogin").click()
|
||||
|
||||
timeout = 10
|
||||
try:
|
||||
wait = WebDriverWait(driver, timeout)
|
||||
WebDriverWait(driver, timeout).until(
|
||||
ec.url_to_be(url + 'SecurityQuestions.aspx') or ec.url_to_be(url + 'Dashboard.aspx')
|
||||
)
|
||||
wait.until(
|
||||
lambda driver: driver.current_url != (url + 'SecurityQuestions.aspx') or (url + 'Dashboard.aspx')
|
||||
)
|
||||
|
||||
if driver.current_url == url + 'SecurityQuestions.aspx':
|
||||
element_present = ec.presence_of_element_located(
|
||||
(By.NAME, 'FBfbforcechangesecurityanswer$txtSecurityAnswer')
|
||||
)
|
||||
WebDriverWait(driver, timeout).until(element_present)
|
||||
driver.find_element_by_name('FBfbforcechangesecurityanswer$txtSecurityAnswer').send_keys(ssn)
|
||||
driver.find_element_by_id("FBfbforcechangesecurityanswer_ibtSubmit").click()
|
||||
|
||||
element_present = ec.presence_of_element_located((By.ID, 'hdnMemberID'))
|
||||
WebDriverWait(driver, timeout).until(element_present)
|
||||
|
||||
if driver.current_url == url + 'Dashboard.aspx':
|
||||
element_present = ec.presence_of_element_located((By.ID, 'Fbscore_divDt'))
|
||||
WebDriverWait(driver, timeout).until(element_present)
|
||||
|
||||
try:
|
||||
driver.find_element(By.ID, "Fbscore_ibtnRefresh").click()
|
||||
except NoSuchElementException:
|
||||
return "BUTTON_NOT_FOUND"
|
||||
|
||||
driver.quit()
|
||||
return "DONE"
|
||||
|
||||
driver.quit()
|
||||
return "ERROR"
|
||||
|
||||
except TimeoutException:
|
||||
driver.quit()
|
||||
return "TIME_OUT"
|
||||
|
||||
except Exception:
|
||||
return "ERROR"
|
||||
Reference in New Issue
Block a user