Mar-31-2017, 01:29 AM
alright, so I have now got a dictionary list from the csv (will call it lookupdictionary for reference)... and a list from the webpage dropdown (will call it matchlist for reference)
________________________________________________________________________________________________
the lookupdictionary is in this format:
{'135': {'creditor': 'MY ASSOCIATION1', 'propert_add': '1111 PROPERTY DR'}, '134': {'creditor': 'CREDITOR2', 'propert_add': '2222 PROPERTY WAY'}, ### ETC.}
This lookupdictionary will be 2-3,000 items
________________________________________________________________________________________________
The matchlist is in this format:
['MY ASSOCIATION1', "MYASSOCIATION2", 'MYASSOCIATION3', 'MYASSOCIATON4', ### ETC.]
The matchlist is around 150 items
* Note that some of these are surrounded by " and some are surrounded by '
____________________________________________________________________________________________
I want to use fuzzywuzzy to loop through each item in the lookupdictionary and search for the "Creditor" Name
{'135': {'creditor': 'MY ASSOCIATION1', 'propert_add': '1111 PROPERTY DR'},
and then return the top match from the matchlist
_______________________________________________________________________________________________
Can anyone help me with this last piece?? below is the current code:
________________________________________________________________________________________________
the lookupdictionary is in this format:
{'135': {'creditor': 'MY ASSOCIATION1', 'propert_add': '1111 PROPERTY DR'}, '134': {'creditor': 'CREDITOR2', 'propert_add': '2222 PROPERTY WAY'}, ### ETC.}
This lookupdictionary will be 2-3,000 items
________________________________________________________________________________________________
The matchlist is in this format:
['MY ASSOCIATION1', "MYASSOCIATION2", 'MYASSOCIATION3', 'MYASSOCIATON4', ### ETC.]
The matchlist is around 150 items
* Note that some of these are surrounded by " and some are surrounded by '
____________________________________________________________________________________________
I want to use fuzzywuzzy to loop through each item in the lookupdictionary and search for the "Creditor" Name
{'135': {'creditor': 'MY ASSOCIATION1', 'propert_add': '1111 PROPERTY DR'},
and then return the top match from the matchlist
_______________________________________________________________________________________________
Can anyone help me with this last piece?? below is the current code:
# -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from itertools import izip import unittest, csv, StringIO from fuzzywuzzy import process class Here(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.implicitly_wait(30) self.base_url = "http://mybaseurl/" self.verificationErrors = [] self.accept_next_alert = True def test_here(self): driver = self.driver driver.get("https://mybaseurl/etc.") self.assertEqual("", driver.title) driver.find_element_by_id("MainContent_Login1_ErlLogin_UserName").clear() driver.find_element_by_id("MainContent_Login1_ErlLogin_UserName").send_keys("My Username") driver.find_element_by_id("MainContent_Login1_ErlLogin_Password").clear() driver.find_element_by_id("MainContent_Login1_ErlLogin_Password").send_keys("My Password") driver.find_element_by_id("MainContent_Login1_ErlLogin_LoginButton").click() self.driver.implicitly_wait(45) driver.find_element_by_css_selector("span.k-input").click() elements = driver.find_elements_by_xpath("//ul[@id='AssociationList_listbox']/li") driver.elements = elements elements_list = [] outputfile = open('temp.csv', 'wb') with outputfile as output: for element in elements: elements_list.append(str(element.text)) print elements_list reader = csv.DictReader(open('c:\\users\\bgutt\\desktop\\input.csv')) input_dict = {} for row in reader: key = row.pop('ourfile') if key in input_dict: pass input_dict[key] = row print input_dict ######################IM HERE############################## def is_element_present(self, how, what): try: self.driver.find_element(by=how, value=what) except NoSuchElementException as e: return False return True def is_alert_present(self): try: self.driver.switch_to_alert() except NoAlertPresentException as e: 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.quit() self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main()