Esempio n. 1
0
def get_answers_html(exam_title):
    logger.info(f"beging: get_answers_html,q = {exam_title}")
    html = ''
    browser = Browser(driver_name='chrome',
                      executable_path='chromedriver.exe',
                      headless=True)
    examtitle = exam_title
    # examtitle = 'POS机、银行卡概述'
    url = 'https://www.tiku88.com/'
    browser.visit(url)
    browser.fill('q', examtitle)
    time.sleep(2)
    browser.find_by_id('search_submit').click()
    time.sleep(2)
    html = browser.html

    while True:
        try:
            browser.find_link_by_partial_text('下一页').first.click()
            time.sleep(3)
            print("追加下一页的内容")
            html += browser.html
        except Exception as e:
            print("没有下一页")
            break
    browser.quit()
    return html
Esempio n. 2
0
def login(username, password):
    browser = Browser('chrome')
    browser.visit('https://www.reg.uci.edu/cgi-bin/webreg-redirect.sh')
    browser.fill('ucinetid', username)
    browser.fill('password', password)
    browser.find_by_name('login_button').click()
    return browser
Esempio n. 3
0
    def run(self):
        browser = Browser(
            'chrome',
            executable_path=
            "C:\Python27\Lib\site-packages\chromedriver_win32\chromedriver.exe",
            service_args=PROXIES)
        # browser = Browser('phantomjs', service_args=PROXIES, user_agent="Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20130401 Firefox/21.0")
        with browser:
            page = 1
            browser.visit(self.url)
            browser.fill("p", self.keyword)
            browser.find_by_id("search-submit").click()

            while True:
                time.sleep(10)
                logging.info("Page " + str(page))
                for link in browser.find_by_css("div.res"):
                    if "applicationname" in link.find_by_css(
                            "a").first["href"].lower():
                        self.queue.put(link.find_by_css("a").first["href"])
                page += 1
                if browser.find_by_css("#pg-next"):
                    browser.find_by_css("#pg-next").click()
                else:
                    break
            self.queue.put(None)
Esempio n. 4
0
def run(general, session, did):
    """ Open the browser, insert access code (if given), 
        insert name, join session and start recording.
    """

    url = session['url']

    browser = Browser()
    browser.driver.maximize_window()
    browser.visit(session['url'])

    if "accessCode" in session:  # Insert access code
        browser.fill('room[access_code]', session['accessCode'])
        browser.find_by_xpath(
            '/html/body/div[2]/div[2]/div/div[2]/div[2]/form/div/input[2]'
        ).click()

    idx = url.find('/gl/')  # BBB Greenlight
    fname = url[idx:len(url)] + "[join_name]"
    browser.fill(fname, general['name'])
    browser.find_by_id('room-join').click()  # Join BBB session

    now = datetime.now()
    ext = session['prefix'] + '-' + now.strftime("%d%m%Y-%H%M")

    out = record(general, session['duration'], did, ext)
    browser.quit()

    return out
    def run(self):
        browser = Browser('chrome',
                          executable_path=EXECUTABLE_PATH,
                          service_args=PROXIES)
        # browser = Browser('phantomjs', service_args=PROXIES, user_agent=USER_AGENT)
        with browser:
            page = 1
            browser.visit(URL)
            browser.fill("q", KEYWORD)
            browser.find_by_name("btnG").click()
            time.sleep(5)

            while True:
                time.sleep(10)
                logging.info("Page " + str(page))
                for link in browser.find_by_css("h3.r"):
                    if "applicationname" in link.find_by_css(
                            "a").first["href"].lower():
                        self.url_queue.put(link.find_by_css("a").first["href"])
                page += 1
                if browser.find_by_css("#pnnext"):
                    browser.find_by_css("#pnnext").click()
                else:
                    break
            self.url_queue.put(None)
Esempio n. 6
0
def begin_login(bilkent_id, password, mail, mail_pass):
    browser = Browser()
    browser.visit('https://stars.bilkent.edu.tr/srs/')

    input_elements = browser.find_by_tag('input')

    pass_field = input_elements[2]
    pass_id = pass_field['id']
    browser.execute_script(
        "var y = document.getElementById(\"LoginForm_password\").type = \"password\""
    )

    browser.fill('LoginForm[username]', bilkent_id)

    browser.type(pass_field['name'], password)
    browser.find_by_name('yt0').click()

    sleep(1)

    raw_email = get_mails(mail, mail_pass)
    verification_code = get_verification_code(raw_email.decode("utf-8"))

    browser.fill("EmailVerifyForm[verifyCode]", verification_code)
    browser.find_by_name('yt0').click()

    sleep(1)
Esempio n. 7
0
def enable():
    import time
    import requests
    import settings
    from splinter import Browser
    from xvfbwrapper import Xvfb

    print "Trying to enable myself."
    vdisplay = Xvfb()
    vdisplay.start()


    email = settings.getEmail()
    password = settings.getPassword()
    team_name = settings.getTeamName()
    bot_user = settings.getBotUser()

    browser = Browser('chrome')
    url = 'https://{}.slack.com/services/{}'.format(team_name, bot_user)
    browser.visit(url)
    browser.fill('email', email)
    browser.fill('password', password)
    browser.find_by_id('signin_btn').first.click()
    browser.find_link_by_text('Enable').first.click()
    time.sleep(2) # Sometimes I saw a crash where there was no alert, so we'll wait a bit first.
    alert = browser.get_alert()
    alert.accept()
    time.sleep(2) # If you close the display too quickly, the request doesn't get processed.

    vdisplay.stop()
Esempio n. 8
0
def start():
    x = input('[+] Post URL: ')
    browser = Browser('chrome')
    # Visit URL
    url = "https://igsub.me"
    url2 = "https://igsub.me/postViews"
    browser.visit(url)
    browser.visit(url2)

    #buttonServer = browser.find_by_value('Get Page (THIS SERVER)').click()

    link = browser.find_by_name('formPostLink').click()
    browser.fill('formPostLink', x)
    # Find and click the 'search' button
    browser.find_by_id('firstFormElementSendButton').click()
    time.sleep(4)

    browser.find_by_name('formPostActionLimit').click()

    count = browser.find_by_value('3000').click()

    send = browser.find_by_id('secondFormElementSendButton').click()

    # Interact with elements
    #button.click()
    while browser.is_text_present('PROCESSING...'):
        print("PROCESSING...")
    else:
        print("Done")
        start()
Esempio n. 9
0
def main(aids):
    livelogin = '******'
    sboxlogin = '******'
    livesearch = 'https://admin.ebizautos.com/index.cfm?section=accounts&page=manage&settings=overview&aid='
    sboxsearch = 'https://admin.sandbox.ebizautos.com/index.cfm?section=accounts&page=manage&settings=overview&aid='
    livecp = 'https://cp.ebizautos.com/index.cfm?ebxid=314'
    sboxcp = 'https://cp.sandbox.bizautos.com/index.cfm?ebxid=314'
    login = False

    while login == False:
        username = input('Username: '******'Password: '******'username', username)
        browser.fill('Password', password)
        try:
            browser.find_by_xpath(
                '/html/body/div[1]/div/div[1]/form/table/tbody/tr[6]/td/div[1]/a'
            ).click()
            time.sleep(2)
            for aid in aids:
                browser.visit(livesearch + str(aid))
                browser.find_by_css(
                    'html body#MainAdminBody div#BodyContainerWide div#MainBody.ClearFix div#LeftNav div.Content div div.Nav3 a'
                ).click()
                browser.driver.find_element_by_tag_name('body').send_keys(
                    Keys.CONTROL, '1')
            login = True
        except:
            print('Login error\a')
            browser.quit()
Esempio n. 10
0
class BaseWebTestCase(LiveServerTestCase):
    """
    Abstract class to handle logic for web tests
    """

    username = "******"
    password = "******"
    wait_seconds = 3.0

    def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument("--window-size=1920,1080")
        chrome_options.add_argument("--start-maximized")
        chrome_options.add_argument("--no-sandbox")
        self.browser = Browser("chrome",
                               headless=False,
                               wait_time=30,
                               options=chrome_options)
        self.browser.driver.set_page_load_timeout(240)
        super(BaseWebTestCase, self).setUp()

    def tearDown(self):
        self.browser.quit()
        super(BaseWebTestCase, self).tearDown()

    def _wait(self):
        time.sleep(self.wait_seconds)

    def _login(self):
        self._visit("")
        self.browser.fill("username", self.username)
        self.browser.fill("password", self.password)
        self.browser.find_by_text("Sign in").first.click()

        assert self.browser.is_text_present(
            "Admin")  # checks that the nav is visible
        assert not self.browser.is_text_present("Sign in")

    def _go_home(self):
        self._visit("/")

    def _setup_confirm(self):
        """
        First part of work-around to let phantomjs accept confirmation dialogs
        http://stackoverflow.com/questions/19903146/confirm-alert-window-in-phantom-js
        """
        js_confirm = "window.confirm = function() { return true }"
        self.browser.execute_script(js_confirm)

    def _accept_confirm(self):
        """
        Second part of work-around to let phantomjs accept confirmation dialogs
        MUST call self._setup_confirm() for this to work
        """
        self.browser.execute_script("return window.confirm")

    def _visit(self, path):
        path = self.live_server_url + path
        self.browser.visit(path)
        self._wait()
class LoginTestCase(unittest.TestCase):
    """
    Proposed solution for task 3.2
    Splinter
    Firefox
    """
    def setUp(self):
        self.browser = Browser()
        self.browser.visit("http://diabcontrol1.herokuapp.com")

    def tearDown(self):
        self.browser.quit()

    def _login(self, username, password):
        self.browser.fill('username', username)
        self.browser.fill('password', password + Keys.RETURN)

    def test_login_success(self):
        self._login('admin', 'admin123')
        page_header = self.browser.find_by_css('.container-fluid .page-header')

        self.assertIn('Welcome to DiabControl system', page_header.text)

    def test_login_failed(self):
        self._login('admin', 'INVALIDpassword')
        alert = self.browser.find_by_css('.container-fluid .form .alert')

        expected_warning = ('Please enter a correct username and password. '
                            'Note that both fields may be case-sensitive.')
        self.assertIn(expected_warning, alert.text)
Esempio n. 12
0
def getEstado():

    browser = Browser('chrome')
    browser.visit('http://scw.pjn.gov.ar/scw/home.seam')
    candadito = browser.find_by_tag('li')[3]
    candadito.click()
    browser.fill('username', 'USERNAME')
    browser.fill('password', 'PASSWORD')
    browser.find_by_id("kc-login").click()
    browser.find_by_css('.fa-list-ul').click()
    browser.find_by_tag('li')[4].click()

    for i in nroExptes:
        try:

            browser.find_by_css('.fa-share').click()
            time.sleep(2)
            browser.find_by_css('.form-control')[1].fill(i['nro'])
            browser.find_by_value('Consultar').click()
            time.sleep(2)
            numero = browser.find_by_css('.column')[0].value
            juzgado = browser.find_by_css('.column')[1].value
            autos = browser.find_by_css('.column')[2].value
            estado = browser.find_by_css('.column')[3].value
            mensaje = autos + ": " + estado
            print mensaje
            resultado.append(mensaje)
        except Exception as e:
            print "Error con expte " + i['nro']

    browser.quit()
    enviarMail()
Esempio n. 13
0
def post_message(create_msg_url, category, title, message, send):
    """
    Create a new U-Cursos forum's message (a.k.a. thread).
    :param category: Specific for community message category
    :param create_msg_url: URL of new message view (syntax is https://www.u-cursos.cl/<institution>/<year>/<semester>/<community>/<section>/foro/mensaje)
    :param title: Message Title
    :param message: Message content
    :param send: Boolean flag to send the message to the forum
    :return:
    """
    # config
    browser = Browser('chrome')
    browser.visit(create_msg_url)

    # log in
    browser.fill(USERNAME_FIELD_NAME, private_credentials.username)
    browser.fill(PASSWORD_FIELD_NAME, private_credentials.password)
    browser.find_by_value(LOG_IN_BUTTON_VALUE).click()

    # build up message
    # choose category
    browser.find_by_id(CATEGORY_CHOSER_ID).first.click()
    browser.find_by_css(CATEGORY_CHOSER_TEXT_INPUT_CSS_CLASS).first.fill(
        "{}\n".format(category))

    # write title
    browser.find_by_name(TITLE_FIELD_NAME).fill(title)

    # write message
    browser.find_by_name(MESSAGE_INPUT_NAME).fill(message)

    # send message (CAUTION)
    if send:
        browser.find_by_value(SEND_BUTTON_VALUE).click()
Esempio n. 14
0
 def test_login(self):
     with pyvirtualdisplay.Display():
         browser = Browser()
         browser.visit("http://ui:8080/accounts/login/")
         browser.fill("login", "testuser")
         browser.fill("password", "password")
         browser.find_by_css(".btn-primary").click()
         self.assertTrue(browser.find_by_text("Successfully signed in as testuser."))
Esempio n. 15
0
 def test_login(self):
     with pyvirtualdisplay.Display():
         browser = Browser()
         browser.visit("http://ui/accounts/login/")
         browser.fill("login", "testuser")
         browser.fill("password", "password")
         browser.find_by_css(".btn-primary").click()
         self.assertTrue(browser.find_by_text("Successfully signed in as testuser."))
Esempio n. 16
0
class BaseWebTestCase(LiveServerTestCase):
    """
    Abstract class to handle logic for web tests
    """
    username = '******'
    password = '******'
    wait_seconds = 3.0

    def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument("--window-size=1920,1080")
        chrome_options.add_argument("--start-maximized")
        chrome_options.add_argument("--no-sandbox")
        self.browser = Browser('chrome',
                               headless=True,
                               wait_time=10,
                               options=chrome_options)
        super(BaseWebTestCase, self).setUp()

    def tearDown(self):
        self.browser.quit()
        try:
            super(BaseWebTestCase, self).tearDown()
        except IndexError:
            print("Ignoring IndexError in tearDown...")

    def _login(self):
        self._visit("")
        self.browser.fill('username', self.username)
        self.browser.fill('password', self.password)
        self.browser.find_by_text('Sign in').first.click()

        assert self.browser.is_text_present('Home')
        assert not self.browser.is_text_present('Sign in')

    def _go_home(self):
        self.browser.click_link_by_text('Home')
        time.sleep(self.wait_seconds)

    def _setup_confirm(self):
        """
        First part of work-around to let phantomjs accept confirmation dialogs
        http://stackoverflow.com/questions/19903146/confirm-alert-window-in-phantom-js
        """
        js_confirm = 'window.confirm = function() { return true }'
        self.browser.execute_script(js_confirm)

    def _accept_confirm(self):
        """
        Second part of work-around to let phantomjs accept confirmation dialogs
        MUST call self._setup_confirm() for this to work
        """
        self.browser.execute_script('return window.confirm')

    def _visit(self, path):
        path = self.live_server_url + path
        self.browser.visit(path)
        time.sleep(self.wait_seconds)
Esempio n. 17
0
class TestBaseViews(StaticLiveServerTestCase):
    """Integration test suite for testing the views in the app: base.

    Test the url for home and the basefiles like robots.txt and humans.txt

    Attributes
    ----------
    browser : Browser
        Driver to navigate through websites and to run integration tests.
    """

    def setUp(self):
        """Initialize the browser, before running the tests.
        """
        self.browser = Browser('chrome')

    def tearDown(self):
        """At the end of tests, close the browser
        """
        self.browser.driver.close()
        self.browser.quit()

    def test_robots(self):
        """Test for url 'base:base_files(robots.txt)'.

        Visit the url of robots.txt and check it loads the file
        """
        self.browser.visit(self.live_server_url + reverse('base_files',
                           kwargs={'filename': 'robots.txt'}))
        self.assertTrue(self.browser.is_text_present('robotstxt'))

    def test_humans(self):
        """Test for url 'base:base_files(humans.txt)'.

        Visit the url of humans.txt and check it loads the file
        """
        self.browser.visit(self.live_server_url + reverse('base_files',
                           kwargs={'filename': 'humans.txt'}))
        self.assertTrue(self.browser.is_text_present('humanstxt'))

    def test_access_to_help(self):
        """ Test that help is accesible via de help button
        """
        test_username = '******'
        test_password = '******'
        self.thelma = get_user_model().objects.create_user(
            username=test_username, email='*****@*****.**', password=test_password,
            first_name='Thelma', last_name='Thelmapellido')
        administrators = Group.objects.get_or_create(name=ADMINISTRADOR_GROUP)[0]
        administrators.user_set.add(self.thelma)
        administrators.save()
        self.browser.visit(self.live_server_url + reverse('tosp_auth:login'))
        self.browser.fill('username', test_username)
        self.browser.fill('password', test_password)
        self.browser.find_by_id('login-submit').click()
        self.browser.find_by_id('my-account-btn').click()
        self.browser.find_by_id('help_button').click()
        self.assertTrue(self.browser.is_text_present('Página de ayuda'))
Esempio n. 18
0
 def test_admin_login(self):
     with pyvirtualdisplay.Display():
         browser = Browser()
         browser.visit("http://ui:8080/admin/")
         self.assertTrue(browser.find_by_text("Django administration"))
         browser.fill("username", "sfmadmin")
         browser.fill("password", "password")
         browser.find_by_value("Log in").click()
         self.assertTrue("Welcome" in browser.html)
Esempio n. 19
0
def main():
    browser= Browser(driver_name="chrome")
    browser.visit("https://www.baidu.com")
    browser.fill('wd','百家号')
    time.sleep(1)
    button=browser.find_by_id("su")
    button.click()
    while true:
        pass
Esempio n. 20
0
 def test_admin_login(self):
     with pyvirtualdisplay.Display():
         browser = Browser()
         browser.visit("http://ui/admin/")
         self.assertTrue(browser.find_by_text("Django administration"))
         browser.fill("username", "sfmadmin")
         browser.fill("password", "password")
         browser.find_by_value("Log in").click()
         self.assertTrue("Welcome" in browser.html)
Esempio n. 21
0
def fb_marketplace(login_name, login_pw, title, pic_path, description, price, plz, street, company, phone):
    url = "https://www.facebook.com"
    browser = Browser('chrome')
    browser.driver.set_window_size(1200, 900)
    browser.visit(url)
    browser.fill('email', login_name)
    browser.fill('pass', login_pw)
    browser.find_by_id("loginbutton").click()
    time.sleep(6)
    browser.find_by_text('Marketplace').click()
Esempio n. 22
0
 def open_download_tab(self, track_list):
     for track in track_list:
         try:
             browser = Browser('chrome')
             browser.visit('http://google.com')
             print track
             browser.fill('q', track[0] + ' ' + track[1] + ' download free')
             browser.find_by_name('btnG').first.click()
         except Exception:
             pass
Esempio n. 23
0
def main():
    browser = Browser()
    browser.visit("http://www.baidu.com")
    browser.fill('wd', 'python')
    button = browser.find_by_id('su')
    button.click()
    if browser.is_text_present('splinter.cobrateam.info'):
        print("Yes, the official website was found!")
    else:
        print("No, it wasn't found... We need to improve our SEO techniques")
Esempio n. 24
0
class Lovebrowser(object):
    def __init__(self):
        self._browser = Browser('chrome')
        self._browser.visit("http://www.welovewe.com/sns/register.aspx")
        self._browser.fill('ctl00$ContentPlaceHolder1$userEmail', userEmail)
        self._browser.fill('ctl00$ContentPlaceHolder1$userPass', passPass)
        self._browser.find_by_css('.button').first.click()

    @property
    def browser(self):
        return self._browser
Esempio n. 25
0
def test():
    IATA_codes = scraping_hubs.scrape_hubs()
    # IATA_coordinates = []

    # # define the chromedriver path
    # executable_path = {"executable_path": "chromedriver.exe"}
    # # set options on browser for no notifications
    # options = webdriver.ChromeOptions()
    # options.add_argument("--disable-notifications")
    # # create a new broswer object
    # browser = Browser("chrome", **executable_path, headless=False, options = options)

    # for hub in IATA_codes:
        
    #     locations_url = "https://www.latlong.net/"
    #     browser.visit(locations_url)
    #     # find textbox to fill (you can also search for it with .find_by_id())
    #     # inputbox = browser.find_by_name('place')
    #     # print(inputbox)
    #     # fill in the textbox
    #     browser.fill(hub)
    #     # click
    #     browser.find_by_id('btnfind').first.click()
    #     coords_html = browser.html
    #     coords_soup = bs(coords_html, "html.parser")

        
        
    #     coordinates = soup.find('span', class_="coordinatetxt")
    #     IATA_coordinates.append(coordinates.text)

    # browser.quit()

    IATA_coordinates = []
    executable_path = {"executable_path": "chromedriver.exe"}
    browser = Browser("chrome", **executable_path, headless=False)

    for hub in IATA_codes:
        locations_url = "https://www.google.com/maps"
        browser.visit(locations_url)
        time.sleep(10)
        # with open("test_html.txt", "w") as text_file:
        #     text_file.write(browser.html)
        # test_id = browser.find_by_id('searchboxinput')
        # print(test_id)
        browser.fill('q', hub)
        # browser.has_class('.searchbox-searchbutton').first.click()
        # browser.click_link_by_id('searchbox-searchbutton')
        browser.find_by_id('searchbox-searchbutton').first.click()
        coords_html = str(browser.html).split("@",2)[1]
        coordinates = coords_html.split(",17z/",2)[0]
        IATA_coordinates.append(coordinates)
        
    browser.quit()
Esempio n. 26
0
def setHtml(roomDay, config):
    b = Browser(driver_name='chrome')
    url = htmlDir
    b.visit(url)
    b.select('selLocation', config['room'])
    b.fill('textDescription', config['text'])
    b.select('selStartMonth', roomDay.month)
    b.select('selStartDay', roomDay.day)
    b.select('selStartTime', config['startTime'])
    b.select('selEndTime', config['endTime'])
    b.click_link_by_id('submit')
Esempio n. 27
0
class AuthedSplinterTestCase(ChannelsLiveServerTestCase):
    def setUp(self):
        self.browser = Browser('chrome', headless=True)

        user = AuthUserFactory()
        self.browser.visit(f'{self.live_server_url}{reverse("users:login")}')
        self.browser.fill('username', user.username)
        self.browser.fill('password', "password")
        self.browser.find_by_text("Login")[0].click()

    def tearDown(self):
        self.browser.quit()
Esempio n. 28
0
class qiangpiao():
    def __init__(self):
        self.login_url = "https://kyfw.12306.cn/otn/login/init"
        # self.driver = Browser(driver_name='chrome', executable_path="C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe")
        self.driver = Browser(
            driver_name='chrome',
            executable_path="/Users/chenchao/Downloads/chromedriver")
        self.login()

    def login(self):
        self.driver.visit(self.login_url)
        self.driver.fill("loginUserDTO.user_name", "user")
        self.driver.fill("userDTO.password", "pwd")
Esempio n. 29
0
def test2(address, emm_stuff):
    address_tmp = address.split(',')
    address = "%s, %s, %s, %s" % (address_tmp[0], address_tmp[1], state,
                                  address_tmp[2])
    try_again = True
    while (try_again):
        try:
            f = open(filename, 'a')
            browser = Browser()
            browser.visit('http://www.centurylink.com/')
            browser.find_by_id('landingRes').first.click()
            browser.find_by_id('home-speed-check').first.click()
            browser.find_by_id('ctam_new-customer-link').first.click()
            browser.is_text_present(
                'Please enter your service address so we can show you accurate pricing product availability in your area',
                wait_time=5)
            browser.fill('form.singleLineAddress', address)
            browser.is_element_present_by_css(
                '.ui-autocomplete.ui-menu.ui-widget.ui-widget-content.ui-corner-all',
                15)
            addressFound = browser.find_by_css(
                '.ui-autocomplete.ui-menu.ui-widget.ui-widget-content.ui-corner-all li a'
            ).first.text
            browser.find_by_css(
                '.ui-autocomplete.ui-menu.ui-widget.ui-widget-content.ui-corner-all li a'
            ).first.click()

            addressFound_formatted = re.sub(r'%s (\d+)' % (state),
                                            r'%s,\1' % (state), addressFound)
            addressFound_formatted = re.sub(',USA', '', addressFound_formatted)
            browser.is_text_present('Choose an Offer', wait_time=5)
            try:
                element = browser.find_by_css('.highestSpeed')
            except:
                element = browser.find_by_css('.dialupOnly')
            extracted_speed_match = re.search("(\d+\.?\d?)", element.text)
            output = re.sub(
                '\s+', ' ',
                addressFound_formatted + ', ' + extracted_speed_match.group(0))
            print output
            f.write(output + ",%s,%s,%s\n" %
                    (emm_stuff[0], emm_stuff[1], emm_stuff[2]))
            browser.quit()
            try_again = False
            f.close()
        except:
            try_again = False
            e = open('bad_addresses', 'a')
            e.write(address + '\n')
            e.close()
            browser.quit()
Esempio n. 30
0
class TrackListScraper(object):

    def __init__(self, artists, year):
        self.browser = Browser('chrome')
        self.artists = artists
        self.year = year
        self.browser.visit('http://1001tracklists.com')

    def execute_full_scrape(self):
        artist_tracklists = {}
        for artist in self.artists:
            artist_tracklists[artist] = self.scrape_per_artist(artist)
        self.browser.quit()
        return artist_tracklists

    def scrape_per_artist(self, artist):
        """Execute the same scrape but instead using the python splinter library
        """

        self.browser.fill('main_search', artist + ' edc ' + self.year)

        self.browser.find_by_id('btn_search').first.click()

        try:
            self.browser.click_link_by_partial_text('2014-06-')
            track_strings = self.get_track_list_for_set(artist)
            return track_strings
        except ElementDoesNotExist:
            pass

    def get_track_list_for_set(self, artist):
        soup = BeautifulSoup(self.browser.html)
        track_values = soup.find_all('div', class_='trackValue')

        track_strings = []
        file = open('tracklist-' + artist + '-edc' + self.year, 'w')
        for track in track_values:
            if track.a:
                track_string = track.a.string
                file.write(track_string)
                # track details in format [artist, trackname]
                track_details = self.parse_track_string(track_string)
                track_strings.append(track_details)
        file.close()
        return track_strings

    def parse_track_string(self, track_string):
        track_info = track_string.strip().split('-')
        for i in range(len(track_info)):
            track_info[i] = track_info[i].strip()
        return track_info
def traverse(url):
    browser = Browser()
    browser.visit(url)
    file = open("student_list.txt")
    enrollment_no = file.read().split()

    for line in enrollment_no:
        time.sleep(1)
        browser.fill("eno", line)
        button = browser.find_by_value("Submit").click()
        time.sleep(3)
        capture()
        button = browser.click_link_by_text("Back ")
    file.close()
Esempio n. 32
0
def main():
    browser = Browser()
    browser.visit('http://www.baidu.com')
    browser.fill('q', 'splinter - python acceptance testing for web applications')
    button = browser.find_by_name('btnK')
    button.click()

    if browser.is_text_present('splinter.cobrateam.info'):
        print 'yes, the official website was found!'
    else:
        print "No, it wasn't found... We need o improve our SEO techniques"

    
    browser.quit()
Esempio n. 33
0
class TestViews(unittest.TestCase):
    def setUp(self):
        """ Test setup """
        self.browser = Browser("phantomjs")

        # Set up the tables in the database
        Base.metadata.create_all(engine)

        # Create an example user
        self.user = User(name="Alice",
                         email="*****@*****.**",
                         password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()

        self.process = multiprocessing.Process(target=app.run,
                                               kwargs={"port": 8080})
        self.process.start()
        time.sleep(1)

    def tearDown(self):
        """ Test teardown """
        # Remove the tables and their data from the database
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        self.browser.quit()

    def test_2_add_post(self):
        self.browser.visit("http://127.0.0.1:8080")
        print("current url = ", self.browser.url)

        self.browser.driver.set_window_size(1920, 1080)
        self.browser.click_link_by_text('login')
        print("current url = ", self.browser.url)

        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        print(self.browser.url)

        add_link = self.browser.find_link_by_partial_text('add')
        add_link.click()
        print(self.browser.url)

        title = "test_acceptance_add_post"
        self.browser.fill("title", title)
        now = datetime.datetime.now()
        now = str(now)
        self.browser.fill("content", now)
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        print(self.browser.url)

        new_post_appears = self.browser.is_text_present(
            title) and self.browser.is_text_present(now)
        print("new_post_appears = ", new_post_appears)
        self.assertEqual(new_post_appears, True)
Esempio n. 34
0
def main2():
    from splinter import Browser

    browser = Browser('chrome')
    browser.visit('http://google.com')
    browser.fill('q', 'splinter - python acceptance testing for web applications')
    browser.find_by_name('btnG').click()

    if browser.is_text_present('splinter.readthedocs.io'):
        print "Yes, the official website was found!"
    else:
        print "No, it wasn't found... We need to improve our SEO techniques"

    browser.quit()
Esempio n. 35
0
class TrackListScraper(object):
    def __init__(self, artists, year):
        self.browser = Browser('chrome')
        self.artists = artists
        self.year = year
        self.browser.visit('http://1001tracklists.com')

    def execute_full_scrape(self):
        artist_tracklists = {}
        for artist in self.artists:
            artist_tracklists[artist] = self.scrape_per_artist(artist)
        self.browser.quit()
        return artist_tracklists

    def scrape_per_artist(self, artist):
        """Execute the same scrape but instead using the python splinter library
        """

        self.browser.fill('main_search', artist + ' edc ' + self.year)

        self.browser.find_by_id('btn_search').first.click()

        try:
            self.browser.click_link_by_partial_text('2014-06-')
            track_strings = self.get_track_list_for_set(artist)
            return track_strings
        except ElementDoesNotExist:
            pass

    def get_track_list_for_set(self, artist):
        soup = BeautifulSoup(self.browser.html)
        track_values = soup.find_all('div', class_='trackValue')

        track_strings = []
        file = open('tracklist-' + artist + '-edc' + self.year, 'w')
        for track in track_values:
            if track.a:
                track_string = track.a.string
                file.write(track_string)
                # track details in format [artist, trackname]
                track_details = self.parse_track_string(track_string)
                track_strings.append(track_details)
        file.close()
        return track_strings

    def parse_track_string(self, track_string):
        track_info = track_string.strip().split('-')
        for i in range(len(track_info)):
            track_info[i] = track_info[i].strip()
        return track_info
Esempio n. 36
0
class StudentSplinterTestCase(ChannelsLiveServerTestCase):

    fixtures = ['workshops', "languages", "problems", "problem_tests"]

    def setUp(self):
        self.browser = Browser('chrome', headless=True)
        self.browser.visit(f'{self.live_server_url}{reverse("workshop_auth")}')
        self.workshop = Workshop.objects.get(pk=1)
        self.workshop.start()
        self.browser.fill('code', self.workshop.code)
        self.browser.click_link_by_id("submit-id-submit")

    def tearDown(self):
        self.browser.quit()
Esempio n. 37
0
def checkin(confirmation, first, last, email, run_time):
    """Check in to a flight.

    Arguments:
    confirmation -- your confirmation number
    first -- your first name
    last -- your last name
    email -- email address to send confirmation
    run_time -- the time you need to check in
    """
    browser = Browser('zope.testbrowser', ignore_robots=True)
    browser.visit('https://www.southwest.com/flight/retrieveCheckinDoc.html')
    browser.fill('confirmationNumber', confirmation)
    browser.fill('firstName', first)
    browser.fill('lastName', last)

    delta = run_time - datetime.now()
    time.sleep(delta.total_seconds())

    submit = browser.find_by_name('submitButton')
    submit.click()
    if browser.find_by_id('errors_props_wrapper') != []:
        browser.quit()
        raise RuntimeError("Info is incorrect or you checked in too early")

    check_in = browser.find_by_name('printDocuments')
    check_in.click()

    email = browser.find_by_id('optionEmail')
    email.click()
    browser.fill('emailAddress', email)
    cont = browser.find_by_name('book_now')
    cont.click()

    browser.quit()
Esempio n. 38
0
def main():
    browser = Browser()
    browser.visit('http://www.baidu.com')
    browser.fill('q',
                 'splinter - python acceptance testing for web applications')
    button = browser.find_by_name('btnK')
    button.click()

    if browser.is_text_present('splinter.cobrateam.info'):
        print 'yes, the official website was found!'
    else:
        print "No, it wasn't found... We need o improve our SEO techniques"

    browser.quit()
class LiveServerSplinterAuthTest(LiveServerTestCase):
    @classmethod
    def setUpClass(cls):
        super(LiveServerSplinterAuthTest, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LiveServerSplinterAuthTest, cls).tearDownClass()

    def setUp(self):
        self.user1 = UserFactory()
        self.user1.set_password('secret')
        self.user1.save()

        self.client1 = ClientFactory()

        self.category1 = CategoryFactory(name='Chairs')
        self.category2 = CategoryFactory(name='Tables')

        self.product1 = ProductFactory(category=self.category1)
        self.product2 = ProductFactory(category=self.category1)
        self.product3 = ProductFactory(category=self.category2)

        self.browser = Browser()
        self.login_helper(self.user1.username, 'secret')

    def tearDown(self):
        self.browser.quit()

    def login_helper(self, username, password):
        self.browser.visit('{}{}'.format(self.live_server_url,
                                         '/accounts/login/'))

        self.browser.fill('username', username)
        self.browser.fill('password', password)
        self.browser.find_by_value('Log in').first.click()

    def test_redirected_to_menu_after_login(self):
        self.assertTrue(self.browser.is_text_present('Select An Option'))

    def test_new_quote_button(self):
        self.browser.visit('{}{}'.format(self.live_server_url, '/menu'))
        new_quote_visible = self.browser.find_by_id('new_quote').visible
        self.assertFalse(new_quote_visible)

        self.browser.find_by_id('btn_new_quote').click()
        self.assertTrue(self.browser.is_text_present('New Quote'))
        sleep(1)
        new_quote_visible = self.browser.find_by_id('new_quote').visible
        self.assertTrue(new_quote_visible)
class TestViews(unittest.TestCase):
    def setUp(self):
        """ Test Setup """
        # If running on a server w/o desktop support, install and use
        # Xvfb to create a headless version of Firefox.
        # http://scraping.pro/use-headless-firefox-scraping-linux/
        self.browser = Browser("firefox")

        # Set up the tables in the database
        Base.metadata.create_all(engine)

        # Create an example user
        self.user = User(name="Alice", email="*****@*****.**",
            password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()

        # NOTE learn more about 'multiprocessing'.  Can run/control
        # other code simultaneously. 
        self.process = multiprocessing.Process(target=app.run,
            kwargs={"port": 8080})

        self.process.start()
        time.sleep(3)

    def test_login_correct(self):
        self.browser.visit("http://127.0.0.1:8080/login")
        self.browser.fill("email", "*****@*****.**")
        sekf.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click
        self.assertEqual(self.browser.url, "http://127.0.0.1:8080/")

    # def test_login_incorrect(self):
    #     self.browser.visit("http://127.0.0.1:8080/login")
    #     self.browser.fill("email", "*****@*****.**")
    #     self.browser.fill("password", "test")
    #     button = self.browser.find_by_css("button[type=submit]")
    #     button.click()
    #     self.assertEqual(self.browser.url, "http://127.0.0.1:8080/login")

    def tearDown(self):
        """ Test teardown """
        # Remove the tables and their data from the database
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        self.browser.quit()
Esempio n. 41
0
	def passwd(self):
		if len(self.login) < 1 or len(self.panic) < 1 or len(self.user) < 1:
			return false
	
		b = Browser()
		b.driver.set_window_size(900,900)
		try:
		    b.visit("https://accounts.google.com/ServiceLogin?service=accountsettings")
		    b.fill('Email',self.user)
		    btn = b.find_by_id("next")
		    btn.click()
		    b.fill('Passwd',self.login)
		    btn = poll_for("#signIn", b)
		    
		    btn.click()
		    
		    b.visit("https://myaccount.google.com/security#signin")
		    btn = b.find_by_css(".vkq40d").first
		    if not btn == None:
			print "not none"
			btn.click()
			poll_fill('Email',self.user, b)
                        btn = b.find_by_id("next")
                        btn.click()
                        poll_fill('Passwd',self.login, b)
                        btn = b.find_by_id("signIn")
                        btn.click()

		    time.sleep(INV)
		    btn = poll_for(".TCRTM", b)
		    btn.click()
		    poll_fill('Passwd',self.login, b)
		    btn = b.find_by_id("signIn")
		    btn.click()
		    p = poll_for(".Hj", b)
		    p.fill(self.panic)
		    p = b.find_by_css(".Hj")[1]
		    p.fill(self.panic)
		    btn = b.find_by_css(".Ya")
		    btn.click()
		    time.sleep(INV*5)
		    b.quit()
		except:
		    traceback.print_exc(file=sys.stdout)
            	    raw_input("Something went wrong...")
		    b.quit()
		    if self.attempts < self.max_attempts:
		        self.attempts += 1
		        self.passwd()
Esempio n. 42
0
def _navigate():
	browser = Browser()
	browser.visit('http://greekbill.com')

	#sign in
	browser.fill('txtUID', 'RemovedForGithub')
	browser.fill('txtPwd', 'RemovedForGiyhub')
	browser.find_by_name('imageField').first.click()

	#switch to admin account
	#browser.find_by_xpath("//select/option[@value='R32486,C34351']").click()

	#Charge Members
	browser.visit('https://www.greekbill.com/GBWEB/AddCharges.aspx')
	return browser
Esempio n. 43
0
	def passwd(self):
		if len(self.login) < 1 or len(self.panic) < 1 or len(self.user) < 1:
			return false
			
		b = Browser()
		b.visit("https://login.live.com")
		#e = b.find_by_id("idDiv_PWD_UsernameExample")
		b.fill("loginfmt",self.user)
		b.fill("passwd",self.login)
		b.driver.set_window_size(900,900)
		btn = b.find_by_value("Sign in")
		btn.mouse_over()
		btn.double_click()
		b.visit("https://account.live.com/password/change?mkt=en-US")
		b.quit()
Esempio n. 44
0
class TestViews(unittest.TestCase):
    def setUp(self):
        """ Test setup """
        self.browser = Browser("phantomjs")

        # Set up the tables in the database
        Base.metadata.create_all(engine)

        # Create an example user
        self.user = User(name="Alice", email="*****@*****.**",
                         password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()

        self.process = multiprocessing.Process(target=app.run, kwargs={"port": 8080})
        self.process.start()
        time.sleep(1)


    def tearDown(self):
        """ Test teardown """
        # Remove the tables and their data from the database
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        self.browser.quit()
    
    def test_2_add_post (self):
        self.browser.visit("http://127.0.0.1:8080")
        print ("current url = ", self.browser.url)
        
        self.browser.driver.set_window_size(1920, 1080)
        self.browser.click_link_by_text('login')
        print ("current url = ", self.browser.url)
        
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        print (self.browser.url)
        
        add_link=self.browser.find_link_by_partial_text('add')
        add_link.click()
        print (self.browser.url)
        
        title="test_acceptance_add_post"
        self.browser.fill("title", title)
        now=datetime.datetime.now()
        now=str(now)
        self.browser.fill("content", now)
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        print(self.browser.url)
        
        new_post_appears=self.browser.is_text_present(title) and self.browser.is_text_present(now)
        print ("new_post_appears = ", new_post_appears)
        self.assertEqual(new_post_appears, True)
class TestViews(unittest.TestCase):
    
    def setUp(self):
        # Test setup 
        self.browser = Browser("phantomjs")
        
        #setup the tables in the database
        Base.metadata.create_all(engine)
        
        #create an example user
        
        self.user = User(name="Alice", email="*****@*****.**",
                        password=generate_password_hash("test"))
        session.add(self.user)
        
        self.entry = Entry(title="test entry", content="test content")
        session.add(self.entry)
        
        session.commit()
        self.process = multiprocessing.Process(target=app.run)
        self.process.start()
        time.sleep(1)

    def tearDown(self):
        """ Test teardown """
        #Remove the tables and their data from the database
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        self.browser.quit()
        
    def test_login_correct(self):
        self.browser.visit("http://127.0.0.1:5000/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        #print(self.browser.url)
        #print('asdf')
        time.sleep(1)
        self.assertEqual(self.browser.url, "http://127.0.0.1:5000/")
    
    def test_login_incorrect(self):
        self.browser.visit("http://127.0.0.1:5000/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        time.sleep(1)
        self.assertEqual(self.browser.url, "http://127.0.0.1:5000/login")
    
    #my acceptance test
    def test_edit_entry_requires_login(self):
        self.browser.visit("http://127.0.0.1:5000/entry/1/edit")
        time.sleep(1)
        self.assertEqual(self.browser.url, "http://127.0.0.1:5000/login?next=%2Fentry%2F1%2Fedit")
Esempio n. 46
0
def getRoutes(start, end):
    browser = Browser(driver_name="firefox")
    browser.visit("https://www.hopstop.com/search?xfr=cityscape")
    print(browser.url)
    browser.fill("address1", str(start))
    browser.fill("address2", str(end))
    browser.find_by_name("get_dirs").click()
    print(browser.url)
    if browser.is_text_present("Did you mean?"):
        browser.click_link_by_href("#")
        if browser.is_text_present("Did you mean?"):
            browser.click_link_by_href("#")
    browser.click_link_by_href("#")
    links = browser.find_link_by_partial_href("/station?stid")
    results = []
    for link in links:
        results.append(link.value)
    return results
Esempio n. 47
0
def Login(userName, Password):
    br = Browser('chrome')
    urlLogin = "******"
    br.visit(urlLogin)
    soup = BeautifulSoup(br.html)
    if soup.get_text().find("Login") == -1:     #can't find Login page
        br.quit()
        return br, False
    #print br.html
    br.fill("user_name", userName)
    br.fill("user_password", Password)
    button = br.find_by_name('not_important')
    button.click()
    soup = BeautifulSoup(br.html)
    if soup.get_text().find("Welcome:") == -1:  #didn't login ok
        br.quit()
        return br, False
    return br, True
Esempio n. 48
0
class TestViews(unittest.TestCase):
    def setUp(self):
        """ Test setup """
        self.browser = Browser("phantomjs")

        # Set up the tables in the database
        Base.metadata.create_all(engine)

        # Create an example user
        self.user = models.User(name="Alice", email="*****@*****.**",
                                password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()

        self.process = multiprocessing.Process(target=app.run)
        self.process.start()
        time.sleep(1)
        

    def test_add_post(self):
        log= logging.getLogger("unittest.TestCase")
        
        ################################## Login as Alice
        #self.browser.visit("http://0.0.0.0:8080/login") # original line
        self.browser.visit("http://127.0.0.1:5000/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        #self.assertEqual(self.browser.url, "http://0.0.0.0:8080/") # original line
        # self.assertEqual(self.browser.url, "http://127.0.0.1:5000/") # ask sam about this line
        
############################################ add a test post #####################
        self.browser.visit("http://127.0.0.1:5000")
        self.browser.click_link_by_partial_href('add')
        self.browser.fill("title", "post test1 title")
        self.browser.fill("content", "post test1 content")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        post_found = self.browser.find_by_tag('h1').value #cheated here - made template title h2. how do we access? index?
        #post_found = self.browser.find_by_text('post test1 title').value - didnt work
        
        log.debug( "FIRSTH1= %r", post_found )
        
        self.assertEqual(post_found, "post test1 title")

    def tearDown(self):
        """ Test teardown """
        # Remove the tables and their data from the database
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        self.browser.quit()
Esempio n. 49
0
class AddTask(TestCase):

    def setUp(self):
        self._browser = Browser('django')

    def test_add_task(self):
        filename = os.path.join(os.path.dirname(__file__),
                                '../../docs/features/add_task.feature')
        run(filename, self, verbose=True)

    def step_user_exists(self, username):
        r'user "([^"]+)" exists'

        user = UserFactory.build(username=username)
        user.is_staff = True
        user.set_password(username)
        user.save()

    def step_I_visit_page_as_logged_user(self, page, username):
        r'I visit "([^"]+)" as logged user "([^"]+)"'

        self._browser.visit('/admin/')
        self._browser.fill('username', username)
        self._browser.fill('password', username)
        self._browser.find_by_value('Log in').first.click()
        self._browser.visit(page)

    def step_I_enter_value_in_field(self, value, field):
        r'I enter "([^"]+)" in field "([^"]+)"'

        self._browser.fill(field, value)

    def step_I_press(self, button):
        r'I press button "([^"]+)"'

        self._browser.find_by_name(button).first.click()

    def step_I_see_task_on_tasks_list(self, task):
        r'I see task "([^"]+)" on tasks list'

        task_on_list = self._browser.find_by_xpath('//ul[@id="todo"]/li[contains(., "%s")]' % task)
        self.assertTrue(task_on_list)
Esempio n. 50
0
class TestViews(unittest.TestCase):
    def setUp(self):
        """ Test setup """
        self.browser = Browser("phantomjs")
        
        # Set up the tables in the database
        Base.metadata.create_all(engine)
        
        # Create an example 
        self.user = models.User(name="Alice", email="*****@*****.**",
                                password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()
        
        self.process = multiprocessing.Process(target=app.run)
        self.process.start()
        time.sleep(1)
        
    def tearDown(self):
        """ Test teardown """
        # Remove the tables and their data from the database
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        self.browser.quit()
        
    def login(self, email, password):
        self.browser.visit(TEST_SITE + "login")
        self.browser.fill("email", email)
        self.browser.fill("password", password)
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        
    def test_login_correct(self):
        self.login("*****@*****.**", "test")
        self.assertEqual(self.browser.url, TEST_SITE)
        
    def test_login_incorrect(self):
        self.login("*****@*****.**", "test")
        self.assertEqual(self.browser.url, TEST_SITE + "login")
        
    def test_add_post(self):
        self.login ("*****@*****.**", "test")
        self.browser.visit(TEST_SITE + "post/add")
        self.browser.fill("title", "acceptance test post 1")
        self.browser.fill("content", "this is the content for the test case")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        self.assertEqual(self.browser.url, TEST_SITE)
        self.assertTrue(
            self.browser.is_text_present("acceptance test post 1"))
Esempio n. 51
0
class TestViews(unittest.TestCase):
    def setUp(self):
        """ Test Setup """
        self.browser = Browser("phantomjs")
        
        # Set up the tables in the database
        Base.metadata.create_all(engine)
        
        # Create an example user
        self.user = User(name="Alice", email="*****@*****.**",
                        password=generate_password_hash("test"))
        session.add(self.user)
        session.commit()

        # multiprocessing module gives you the ability to start and run other code simultaneously with your own scripts
        # also allows you to communicate and control this code, by called methods such as start and terminate
        # also provides features for implements concurrency in your applications
        # in this test, you can't call app.run method as usual because this method is blocking and will stop the tests from running
        # instead, you target which function to run
        self.process = multiprocessing.Process(target=app.run, kwargs={"port": 8080})
        
        self.process.start()
        # time.sleep(1) in order to pause for a second to allow server to start
        time.sleep(1)
    
    def test_login_correct(self):
        self.browser.visit("http://127.0.0.1:8080/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        self.assertEqual(self.browser.url, "http://127.0.0.1:8080/")

    def test_login_incorrect(self):
        self.browser.visit("http://127.0.0.1:8080/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        self.assertEqual(self.browser.url, "http://127.0.0.1:8080/login")
    
    def tearDown(self):
        """ Test Teardown """
        # Remove the tables and their data from the database
        
        # Kill the server
        self.process.terminate()
        session.close()
        engine.dispose()
        Base.metadata.drop_all(engine)
        # Exit the browser
        self.browser.quit()
Esempio n. 52
0
class TestViews(unittest.TestCase):
	def setUp(self):
		"""Test setup"""
		#create an instance of the splinter.Browser class, using the (PhantomJS driver) <-- use for our automation
		self.browser = Browser("phantomjs")

		#set up the tables in the database
		Base.metadata.create_all(engine)

		#create an example user
		self.user = models.User(name="Alice", email="*****@*****.**",
			password=generate_password_hash("test"))

		session.add(self.user)
		session.commit()

		"""
		Understand multiprocessing from lesson, and more
		"""

		#use multiprocessing module in order to start the Flask test server running
		#since we need a server up to run our app, since our test will be visiting the actual site
		self.process = multiprocessing.Process(target=app.run)
		self.process.start()
		time.sleep(1)

	def tearDown(self):
		"""Test teardown"""
		#Remove tables and data from the database
		self.process.terminate()
		Base.metadata.drop_all(engine)
		self.browser.quit()

	def testLoginCorrect(self):
        self.browser.visit("http://0.0.0.0:8080/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        self.assertEqual(self.browser.url, "http://0.0.0.0:8080/")

    def testLoginIncorrect(self):
        self.browser.visit("http://0.0.0.0:8080/login")
        self.browser.fill("email", "*****@*****.**")
        self.browser.fill("password", "test")
        button = self.browser.find_by_css("button[type=submit]")
        button.click()
        self.assertEqual(self.browser.url, "http://0.0.0.0:8080/login")

if __name__ == "__main__":
	unittest.main()
Esempio n. 53
0
def getstatus(pnr):
    browser = Browser()
    url = "http://www.indianrail.gov.in/pnr_Enq.html"
    browser.visit(url)
    time.sleep(5)
    browser.fill("lccp_pnrno1", pnr)
    browser.find_by_name("submit").click()
    time.sleep(2)
    soup = BeautifulSoup(browser.html, "html.parser")
    status = soup.findAll('td', {'class': 'table_border_both'})
    string = ""

    string = "PNR:" + pnr + "," + "TRAIN:" + status[0].text

    string = string + ",DOJ:" + status[2].text.replace(" ", "") + ",CLASS:" + status[7].text.replace(" ", "") + "," + \
             status[3].text.replace(" ", "") + "-" + status[4].text.replace(" ", "")
    string = string + "," + "BOOK:" + status[9].text.replace(" ", "") + ",CUR:" + status[10].text.replace(" ",
                                                                                                          "") + ",FARE:" + \
             status[11].text

    return string
Esempio n. 54
0
	def run(self):
		browser = Browser('chrome', executable_path="C:\Python27\Lib\site-packages\chromedriver_win32\chromedriver.exe", service_args=PROXIES)
		# browser = Browser('phantomjs', service_args=PROXIES, user_agent="Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20130401 Firefox/21.0")
		with browser:
			page = 1
			browser.visit(self.url)
			browser.fill("p", self.keyword)
			browser.find_by_id("search-submit").click()

			while True:
				time.sleep(10)
				logging.info("Page " + str(page))
				for link in browser.find_by_css("div.res"):
					if "applicationname" in link.find_by_css("a").first["href"].lower():
						self.queue.put(link.find_by_css("a").first["href"])
				page += 1
				if browser.find_by_css("#pg-next"):
					browser.find_by_css("#pg-next").click()
				else:
					break
			self.queue.put(None)
Esempio n. 55
0
def twitterMagic():
    print "Twitter Magic Time!!!"
    browser = Browser("firefox")
    browser.visit("https://twitter.com/signup")
    nameslist = grabNames()
    emaillist = grabEmails()
    passlist = grabPasses()
    userlist = grabUsers()
    # for each name in the list, fill the form in with data from the text files
    # note to self - you have to set variables to loop through and pick the next name after the first is signed up
    # STEPS!!!
    # fill name field
    # fill email
    # fill password
    # uncheck check mark
    # click signup button
    # (NEXT PAGE)
    # fill username?
    # profit
    x = 0
    for x in nameslist:
        browser.fill(nameslist[x], "full-name")
        browser.fill(emaillist[x], "email")
        browser.fill(passlist[x], "password")
        browser.fill(userlist[x], "username")
        browser.uncheck("checkbox")
        browser.find_by_name("Sign Up").first.click()
        browser.back()
        x = x + 1
Esempio n. 56
0
def patent_parser(search_exp):
    """@todo: Docstring for patent_parser.
    """
    patent_list = []
    b = Browser("phantomjs")
    b.reload()
    b.visit('http://www.pss-system.gov.cn/sipopublicsearch/search/searchHome-searchIndex.shtml')
    b.fill('searchInfo', search_exp)
    b.click_link_by_text(u'检索')
    b.is_element_not_present_by_css('.s_c_conter', wait_time=8)
    for _ in xrange(10):
        item_list = b.find_by_css('.s_c_conter')
        for item in item_list:
            info_list = item.find_by_tag('td')
            if not urlset.has_url('patent', info_list[0].text[6:]):
                try:
                    patent = Patent(id=info_list[0].text[6:],
                                    path='~',
                                    title=info_list[4].text[6:],
                                    abstract='~',
                                    inventor=info_list[7].text[5:].split(';')[:-1],
                                    applicant=info_list[6].text[10:].split(';')[:-1],
                                    category=info_list[5].text[8:].split('; '),
                                    update_time=time.strftime('%Y-%m-%dT%XZ', time.gmtime()))
                    patent_list.append(patent)
                    print patent.id, 'new'    # @todo logs
                except:
                    print 'error patent'
        if b.is_text_present(u'下一页'):
            b.click_link_by_text(u'下一页')
            b.is_element_not_present_by_css('.s_c_conter', wait_time=8)
        else:
            break
    try:
        solr.add('patent', patent_list)
    except:
        'err adding patent'
    finally:
        b.quit()
Esempio n. 57
0
	def run(self):
		browser = Browser('chrome', executable_path=EXECUTABLE_PATH, service_args=PROXIES)
		# browser = Browser('phantomjs', service_args=PROXIES, user_agent=USER_AGENT)
		with browser:
			page = 1
			browser.visit(URL)
			browser.fill("q", KEYWORD)
			browser.find_by_name("btnG").click()
			time.sleep(5)

			while True:
				time.sleep(10)
				logging.info("Page " + str(page))
				for link in browser.find_by_css("h3.r"):
					if "applicationname" in link.find_by_css("a").first["href"].lower():
						self.url_queue.put(link.find_by_css("a").first["href"])
				page += 1
				if browser.find_by_css("#pnnext"):
					browser.find_by_css("#pnnext").click()
				else:
					break
			self.url_queue.put(None)
Esempio n. 58
-1
def getRoutes(start,end):
    browser = Browser(
        driver_name="firefox"
)
    browser.visit('https://www.hopstop.com/search?xfr=cityscape')
    print(browser.url)
    browser.fill('address1',str(start))
    browser.fill('address2',str(end))
    browser.find_by_name('get_dirs').click()
    print(browser.url)
    if browser.is_text_present('Did you mean?'):
        print "better at least get here"
        #browser.click_link_by_href("#") 
        for link in browser.find_link_by_href("#"):
            print "Okay"
            if link.visible == True:
                print link.text
                browser.click_link_by_text(link.text)
                break
    browser.click_link_by_href("#")
    links = browser.find_link_by_partial_href("/station?stid")
    results = []
    for link in links:
        results.append(link.value)
    browser.quit()
    return results
Esempio n. 59
-1
def open_door():
    start_time = time.time()
    browser = Browser('phantomjs')
    browser.visit("https://www.chalmersstudentbostader.se/login")
    browser.fill('log', options.username)
    browser.fill('pwd', options.password)
    while browser.find_by_text('Logga in') == []:
        sleep(0.05)
    btn = browser.find_by_text('Logga in')[1]
    btn.click() 
    while True:
        while browser.find_by_text('Öppna porten') == []:
            sleep(0.05)
        port = browser.find_by_text('Öppna porten').first
        if not "{aptusUrl}" in port['href']:
            break
        sleep(0.1)
    browser.visit(port['href'])
    door_ids = parse_door_ids(options.door_ids)
    for door_id in door_ids:
        while browser.find_by_id(door_id) == []:
        	sleep(0.1)
        print("Opening door with id: " + door_id)
        btn = browser.find_by_id(door_id).first
        btn.click()
    print(time.time()-start_time)