def post(ext="py"): site["checker"].upload( saveSolution, f"{root}/work-folder/code/code.{ext}", cache["link"], driver.getDriver(cache), root )
def getComplaintDetails(urls, driver_no): driver = getDriver(driver=WEB_DRIVER, driver_no=driver_no) login(driver) print( f'[{driver_no}] >> Begin Crawling Complaint Details for {len(urls)} pages...' ) mongo = MongoHelper() complaints = [] exception_count = 0 timeout_exception_count = 0 page_count = 0 for url in urls: # restart when come across too many timeouts if timeout_exception_count >= RESTART_TIMEOUT_EXCEPTION_COUNT: print( f'[{driver_no}] >> Timeout Excepiton reach {RESTART_EXCEPTION_COUNT}, trying to restart program!' ) restart_program() elif exception_count >= RESTART_EXCEPTION_COUNT: print( f'[{driver_no}] >> Exception reach {RESTART_EXCEPTION_COUNT}, trying to restart program!' ) restart_program() page_count += 1 print(f'\n[{driver_no}] >>>> Complaint {page_count}, URL: {url}') try: time.sleep(SLEEP_NEXT_COMPLAINT) complaint = getComplaintDetail(url, driver, driver_no) print(complaint) complaints.append({'url': url, **complaint}) except Exception as e: print( f'[{driver_no}] >>>> Got Exception: {traceback.format_exc()}, URL: {url}' ) exception_count += 1 if type(e) == TimeoutException: timeout_exception_count += 1 complaint_count = len(complaints) if complaint_count == SAVE_COMPAINT_BATCH: print( f'\n[{driver_no}] >> Writing {complaint_count} complaints to mongo...' ) mongo.update(complaints) complaints = [] # update remaining results if len(complaints) != 0: mongo.update(complaints) print( f'\n[{driver_no}] >> Writing {len(complaints)} complaints to mongo...' ) else: pass print(f'[{driver_no}] >> All Complaints Crawling Completed!')
def test_lines(): www_driver = driver.getDriver() www_driver.get(configure.www_root + "lines.html") log = www_driver.find_element_by_id("logarea") worked = False for i in range(20): if ("Model loaded successfully" in log.text): worked = True break time.sleep(0.5) assert(worked) driver.noSevereErrors(www_driver) www_driver.close()
def test_copypaste(): www_driver = driver.getDriver() www_driver.get(configure.www_root + "copypaste.html") log = www_driver.find_element_by_id("log") worked = False for i in range(20): if ("Model loaded successfully" in log.get_attribute("value")): worked = True break time.sleep(0.5) assert(worked) driver.noSevereErrors(www_driver) www_driver.close()
def test_jquery_1(): """ This should work properly. """ www_driver = driver.getDriver() www_driver.get(configure.www_root + "test/test_jquery_1.html") log = www_driver.find_element_by_id("logarea") worked = False for i in range(20): if ("Model loaded successfully" in log.text): worked = True break time.sleep(0.5) assert (worked) driver.noSevereErrors(www_driver, ignore_404=["p/3010.dat", "p/s/3010s01.dat"]) www_driver.close()
def test_error_handling(): www_driver = driver.getDriver() www_driver.get(configure.www_root + "error.html") worked = False try: WebDriverWait(www_driver, 3).until(EC.alert_is_present(), 'Timed out waiting for PA creation ' + 'confirmation popup to appear.') alert = www_driver.switch_to.alert alert.accept() worked = True except TimeoutException: pass assert worked, "Alert handling failed." www_driver.close()
def test_starting_matrix_3(): """ String of values in LDraw transform format. """ www_driver = driver.getDriver() www_driver.get(configure.www_root + "test/test_starting_matrix_3.html") log = www_driver.find_element_by_id("logarea") worked = False for i in range(20): if ("Model loaded successfully" in log.text): worked = True break time.sleep(0.5) assert (worked) driver.noSevereErrors(www_driver, ignore_404=["p/3010.dat", "p/s/3010s01.dat"]) www_driver.close()
def test_animation(): www_driver = driver.getDriver() www_driver.get(configure.www_root + "anim.html") log = www_driver.find_element_by_id("logarea") select = Select(www_driver.find_element_by_xpath("/html/body/select[1]")) for option in select.options: option.click() worked = False for i in range(20): if ("Model loaded successfully" in log.text): worked = True break time.sleep(0.5) assert(worked) driver.noSevereErrors(www_driver) www_driver.close()
def test_jquery_2(): """ This should create an alert box due to missing parts. """ www_driver = driver.getDriver() www_driver.get(configure.www_root + "test/test_jquery_2.html") worked = False try: WebDriverWait(www_driver, 3).until( EC.alert_is_present(), 'Timed out waiting for PA creation ' + 'confirmation popup to appear.') alert = www_driver.switch_to.alert alert.accept() worked = True except TimeoutException: pass assert worked, "Alert handling failed." www_driver.close()
def play_with_bot(): from dating.bot import Bot from driver import getDriver b = Bot(getDriver()) b._totalLikes
# Author: Stan FortoĊski # Date: 02.05.2020 # Proper Executable from random import random from driver import getDriver from tinder.login.tinderlogin import TinderLogin from tinder.tinderbot import TinderBot from tinder.finder.instagramfinder import InstagramFinder from tinder.finder.snapchatfinder import SnapchatFinder from selenium.common.exceptions import NoSuchElementException from tinder.config import Config from time import sleep driver = getDriver() login = TinderLogin(driver) bot = TinderBot(driver) igFinder = InstagramFinder(driver) snapFinder = SnapchatFinder(driver) errors = 0 print('=== TinderBot Start ===') login.logIn() if login.isLogged(): print('=== Tinder Perform ===') while True: try: bot.perform() igFinder.findAndSaveInstagramNick() snapFinder.findAndSaveSnapchatNick() if bot.getTotalActions() % 10 == 0:
def login(): site["checker"].login(driver.getDriver(cache), root)
def setUpClass(cls): cls.driver = getDriver()
scrollToBottomOfPage(driver, 10) likesPage = driver.page_source parseLikesPage(likesPage, i, outputPath) if __name__ == '__main__': # import sensitive information if running locally from secretDirectory import secret # also get driver file to use from driver import getDriver, Browser from os import getcwd email = secret.EMAIL passw = secret.passw uname = secret.UNAME tor_path = secret.torBrowserPath driver_path = secret.exePath numOfFriendsToScrape = 2 driver = getDriver(driver_path, Browser.FIREFOX, tor_path) loginToFacebook(driver, email, passw) time.sleep(8) FULLHTMLPAGE = getFriendsListHTMLPage(driver, uname) # will parse the HTML page to obtain hrefs of friends. friendURLS = parseFriendsPage(FULLHTMLPAGE) print(friendURLS) print(len(friendURLS)) scrapeLikePages(driver, friendURLS, numOfFriendsToScrape, getcwd()) driver.close()
def setUp(self): driver = getDriver() self.p1 = LoginPage(driver, url) self.p1.openBroswer()
def setUpClass(cls): cls.driver = getDriver() cls.login = TinderLogin(cls.driver) cls.login.logIn()
def setUp(self): self.driver = getDriver()