def get_detail(juego): if (str(juego["id"]) in os.listdir("detalles")): return(1) url = juego["url"] + "/critic-reviews" print(str(juego["id"]) + ' ' + url) chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--headless") driver = WebDriver("chrome", reuse_browser=True,options=chrome_options) driver.set_page_load_timeout(random.randrange(180, 240,1)) try: driver.get(url) except: print("reintentando id {} ,url {}".format(str(juego["id"]).url)) driver.quit() return(get_detail(juego)) Html_file= open("detalles/" + str(juego["id"]),"w") Html_file.write(driver.page_source) Html_file.close() driver.quit() return(1)
def setUpClass(cls): # Allow extra keyword args to pass to WebDriver constructor to be # specified in Django settings kwargs = getattr(settings, 'WEBDRIVERPLUS_KWARGS', {}) cls.browser = WebDriver(browser=browser, **kwargs) super(WebDriverPlusTestCase, cls).setUpClass()
def setUp(self): self.browser = WebDriver('remote', desired_capabilities=webdriverplus.DesiredCapabilities.FIREFOX, command_executor=SAUCELABS_EXECUTOR) self.smtp = smtplib.SMTP('localhost')
class KalalauReservations(unittest.TestCase): def setUp(self): self.browser = WebDriver('remote', desired_capabilities=webdriverplus.DesiredCapabilities.FIREFOX, command_executor=SAUCELABS_EXECUTOR) self.smtp = smtplib.SMTP('localhost') def test_reservations(self): # Go to reservations page, asset we're forwarded to login self.browser.get('https://camping.ehawaii.gov/camping/all,details,1692.html') self.browser.find_element_by_css_selector('a[href="#ui-tabs-8"]').click() self.browser.switch_to_alert().accept() self.assertTrue(self.browser.current_url.startswith('https://lala.ehawaii.gov/lala/login')) # Login username = self.browser.find_element_by_id('username') username.send_keys(LOGIN_USERNAME) self.browser.find_element_by_id('password').send_keys(LOGIN_PW) username.submit() # Set reservation date # self.browser.find_element_by_id('event_checkIn').send_keys(CHECKIN_DATE) # Check the numbers. permit_count_cells = self.browser.find_element_by_link_text('Kalalau').parent().next_all('td') # For testing, comment this out eventually. # self.smtp.sendmail('*****@*****.**', '*****@*****.**', 'Cron ran') for cell in permit_count_cells: print cell.text if cell.text and int(cell.text.strip()) > '0': # It's Kalalau time bro! self.smtp.sendmail(MAILTO, MAILTO, MESSAGE) def tearDown(self): print('Link to job: https://saucelabs.com/jobs/%s' % self.browser.session_id) self.browser.quit() self.smtp.quit()
import csv from webdriverplus import WebDriver from itertools import * csvfile = raw_input("Enter the name of the csv input file . . .") loopcall = raw_input("Infinite loop? (yes/no) . . .") delay = raw_input("Time delay for each URL visit (in seconds) . . . ") delay = int(delay) urls = csv.reader(open(csvfile, "rU")) if loopcall == "yes": for url in cycle(urls): browser = WebDriver('firefox', reuse_browser=True) browser.maximize_window() browser.get(url[0]) time.sleep(delay) elif loopcall == "no": for url in urls: browser = WebDriver('firefox', reuse_browser=True) browser.maximize_window()
go_button_element.click() #Capture and store the value of miles required for the submitted departure date departure_flight_path = '//*[@id="flightTabMiles_0"]' print_departure_flight_miles(departure_flight_path) #Capture and store the value of miles required for the submitted return date return_flight_path = '//*[@id="flightTabMiles_1"]' print_return_flight_miles(return_flight_path) #||||||||||||||||||||||||||||||||||End of Function Definitions|||||||||||||||||||||||||||||||||||||||||||||||| #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Beginning of Program$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ # Create a new instance of the Firefox driver driver = WebDriver('firefox', quit_on_exit=False) current_time() print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||" print "Jet Blue" jet_blue_sign_on() print "-------------------------------------------------------" #jet_blue_search() print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||" print "Alaska Air" alaska_air_sign_on() print "-------------------------------------------------------" #alaska_air_search() print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||"