Example #1
0
    def valid_login(self, username=False):
        self.load_elements()

        if username:
            self.clear_input(self.email, USERNAME)
        else:
            self.clear_input(self.email, EMAIL)
        self.clear_input(self.password, PASSWORD)

        self.submit.send_keys(Keys.RETURN)

        wait = WebDriverWait(self.driver, 3)
        alert = wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, '//div[@id="toast-container"]')))
        text = alert.text
        sleep(5)

        try:
            assert self.driver.current_url == LOGGED_URL
            assert text == 'cool, have fun!!'
            self.result['Valid Login'] = SUCCESS
            if username:
                print_result('Valid Login with username Succeed')
            else:
                print_result('Valid Login with email Succeed')
        except AssertionError:
            if username:
                print_error('Valid Login with username raises an error')
            else:
                print_error('Valid Login with email raises an error')
            self.result['Valid Login'] = FAIL
        sleep(1)
        print()
Example #2
0
File: signup.py Project: rolycg/bot
    def check_cc(self):
        get_url = 'https://api.constantcontact.com/v2/contacts?api_key=8frjx94rfxgfkxt6c75usrrw&email=' + CREATED_EMAIL
        get_data = {
            'headers': {
                'Authorization': 'Bearer ef2ab36e-f853-4546-8ebe-e0113e85cb5b',
                'Content-Type': 'application/json'
            }
        }
        r = requests.request('GET', get_url, **get_data)
        if r.status_code == 200:
            user = json.loads(r.content)
            contacts_id = None
            try:
                contacts_id = user['results'][0]['id']
            except:
                pass
            try:
                assert contacts_id is not None
                print_result('Contact Contact User Added Succeed')
                self.result['Contact Contact User Added'] = SUCCESS
            except AssertionError:
                print_error('Contact Contact User Added Fail')
                self.result['Contact Contact User Added'] = FAIL

            delete_url = 'https://api.constantcontact.com/v2/contacts/' + contacts_id + '?api_key=8frjx94rfxgfkxt6c75usrrw'
            rd = requests.request('DELETE', delete_url, **get_data)
            try:
                assert str(rd.status_code) == '204'
                print_result('Contact Contact User Delete Succeed')
                self.result['Contact Contact User Delete'] = SUCCESS
            except AssertionError:
                print_error('Contact Contact User Delete Fail')
                self.result['Contact Contact User Delete'] = FAIL
Example #3
0
    def google(self):
        self.load_elements()
        main_handle = self.driver.current_window_handle

        google = self.driver.find_element_by_id('login-gl')
        google.click()
        another_window = list(set(self.driver.window_handles) -
                              {main_handle})[0]
        self.driver.switch_to.window(another_window)
        sleep(3)

        email = self.driver.find_element_by_id('identifierId')
        email.send_keys('*****@*****.**')
        next = self.driver.find_element_by_id('identifierNext')
        next.click()
        sleep(2)

        password = self.driver.find_element_by_xpath(
            '//input[@name="password"]')
        password.send_keys('5DDydr9r')
        next = self.driver.find_element_by_id('passwordNext')
        next.click()
        sleep(5)
        self.driver.switch_to.window(main_handle)

        try:
            assert self.driver.current_url == LOGGED_URL
            print_result('Google + success Succeed')
            self.result['Google + success'] = SUCCESS
        except AssertionError:
            print_error('Google + success login raises an error')
            self.result['Google + success'] = FAIL
Example #4
0
def run(conf_path, output_path, definitions):
    try:
        print "configuring"
        if conf_path is not None:
            conf = cfg.load_conf(params.__dict__, conf_path)
            params.__dict__.update(conf)
        if definitions is not None:
            cfg.update_conf(params.__dict__, params.__dict__, definitions)
        
        if params.verbose:
            print "verbose output enabled"
        
        if params.lower_process_priority:
            if params.verbose:
                print "reducing process priority"
            warning = svc.reduce_process_priority()
            if warning:
                output.warn(warning)
        
        if params.graphs:
            if not output_path:
                raise InvocationError("no output directory")
            output_path = os.path.normpath(output_path)
            if params.verbose:
                print "graphs will be written to:", output_path
        output.output_dir = output_path
        
        print "validating"
        cfg.validate()
        
        with mp.TaskPool(params.num_tasks, params.extended_mode, params.__dict__) as task_pool:
            print "executing"
            
            if params.verbose:
                print "number of parallel tasks:", task_pool.num_tasks
            
            start_time = time.time()
            execute(task_pool)
            end_time = time.time()
            elapsed_time = end_time - start_time
            
            print output.div_line
            print "done"
            
            if params.verbose:
                print "finished in %.2f s" % elapsed_time
    except (cfg.ConfigurationError, core.ComputationError, model.exc.ModelError) as exc:
        output.print_error(str(exc))
        sys.exit(1)
    except MemoryError:
        output.print_error("out of memory")
        sys.exit(1)
    except:
        if not debug_mode:
            output.print_exception()
            sys.exit(1)
        else:
            raise
Example #5
0
def process():
    try:
        conf_path = None
        output_path = None
        definitions = []
        
        help_flag = False
        version_flag = False
        extensions_flag = False
        
        opts, args = getopt.getopt(sys.argv[1:], "hvegD:o:")
        for opt, arg in opts:
            if opt == "-h":
                help_flag = True
            elif opt == "-v":
                version_flag = True
            elif opt == "-e":
                extensions_flag = True
            elif opt == "-g":
                global debug_mode
                debug_mode = True
            elif opt == "-D":
                definitions.append(arg)
            elif opt == "-o":
                output_path = arg
            else:
                assert False, "unhandled option"
        if args:
            conf_path = args[0]
        
        if help_flag:
            print_help()
            sys.exit()
        if version_flag:
            print_info()
            sys.exit()
        
        extensions = load_extensions()
        
        if extensions_flag:
            print_extensions(extensions)
            sys.exit()
        
        if conf_path is None:
            raise InvocationError("no input file")
        if len(args) > 1:
            raise InvocationError("too many arguments")
        
        run(conf_path, output_path, definitions)
    except (getopt.GetoptError, InvocationError) as ie:
        output.print_error(str(ie), help_hint)
        sys.exit(2)
Example #6
0
    def facebook(self, success=True):
        self.load_elements()
        main_handle = self.driver.current_window_handle

        facebook = self.driver.find_element_by_id('login-fb')
        facebook.click()
        another_window = list(set(self.driver.window_handles) -
                              {main_handle})[0]
        self.driver.switch_to.window(another_window)
        sleep(3)
        email = self.driver.find_element_by_id('email')
        if success:
            email.send_keys('*****@*****.**')
        else:
            email.send_keys(FACEBOOK_EMAIL)
        sleep(1)
        password = self.driver.find_element_by_id('pass')
        if success:
            password.send_keys('Gerr@rd4')
        else:
            password.send_keys(FACEBOOK_PASSWORD)
        sleep(1)
        login = self.driver.find_element_by_xpath(
            '//label[@id="loginbutton"]/input')
        login.click()
        sleep(5)
        self.driver.switch_to.window(main_handle)
        sleep(1)
        if success:
            try:
                assert self.driver.current_url == LOGGED_URL
                print_result('Facebook success Succeed')
                self.result['Facebook success'] = SUCCESS
            except AssertionError:
                print_error('Facebook success login raises an error')
                self.result['Facebook success'] = FAIL
        else:
            try:
                assert self.driver.current_url == 'https://jazwings.com/login'
                print_result('Facebook failed Succeed')
                self.result['Facebook failed'] = SUCCESS
            except AssertionError:
                print_error('Facebook failed login raises an error')
                self.result['Facebook failed'] = FAIL
        sleep(1)
        print()
Example #7
0
File: signup.py Project: rolycg/bot
 def check_points(self):
     toggle = self.driver.find_elements_by_xpath(
         '//a[@class="dropdown-toggle"]')[0]
     toggle.click()
     links = self.driver.find_elements_by_xpath(
         '//ul[@class="dropdown-menu"]/li/a')
     for link in links:
         if link.text == 'Profile':
             link.click()
     sleep(5)
     span = self.driver.find_element_by_id('creator_pts')
     try:
         assert '100' in span.text
         print_result('User Points Succeed')
         self.result['User Points'] = SUCCESS
     except AssertionError:
         self.result['User Points'] = FAIL
         print_error('User Points Failed')
def process_features(dataframe, *features):
    """one-hot encode each feature that needs encoding, add the new features to the dataframe, and remove the original feature"""
    result = dataframe
    try:
        for feature in features:
            o.print_verbose('  one hotting feature: {}'.format(feature))

            one_hotted = pd.get_dummies(dataframe[feature],
                                        columns=[feature],
                                        prefix=feature)

            o.print_verbose(
                '  {} unique features found'.format(one_hotted.shape[1]), '')

            result = pd.concat([result, one_hotted], axis=1)
            result.drop(columns=[feature], inplace=True)
    except Exception as e:
        o.print_error(e)
    return result
Example #9
0
    def login_link(self):
        login_element = self.driver.find_element_by_id('login')
        login_element.click()
        sleep(2)

        self.load_elements()

        try:
            assert self.driver.current_url == 'https://jazwings.com/login'
            assert self.email is not None
            assert self.password is not None
            assert self.submit is not None
            self.result['Login link'] = SUCCESS
            print_result('Login link Succeed')
        except AssertionError:
            print_error('Login link raises an error')
            self.result['Login link'] = FAIL

        print()
Example #10
0
    def invalid_email(self, username, password, task):
        self.clear_input(self.email, username)
        self.clear_input(self.password, password)
        self.submit.send_keys(Keys.RETURN)

        wait = WebDriverWait(self.driver, 2)
        alert = wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, '//div[@id="toast-container"]')))
        text = alert.text
        sleep(5)
        try:
            assert text == 'Unable to log in with provided credentials.'
            self.result[task] = SUCCESS
            print_result('Invalid email Succeed')
        except AssertionError:
            print_error('Login with random text raises an error')
            self.result[task] = FAIL
        sleep(1)
        print()
Example #11
0
File: signup.py Project: rolycg/bot
    def delete_user(self):
        select_query = "SELECT id FROM auth_user WHERE username='******'" % CREATED_USERNAME
        user_id = None
        self.database.cursor.execute(select_query)
        for _id in self.database.cursor.fetchall():
            user_id = _id[0]

        gamification_query = "DELETE FROM gamification_pointactionperson WHERE user_id='%s'" % user_id
        self.database.cursor.execute(gamification_query)

        query = "DELETE FROM people_person WHERE user_ptr_id IN (SELECT id FROM auth_user WHERE username='******')" % CREATED_USERNAME
        self.database.cursor.execute(query)
        self.database.prod.commit()

        self.database.cursor.execute(select_query)
        exist = False
        try:
            for _ in self.database.cursor.fetchall():
                exist = True
                break
        except psycopg2.ProgrammingError:
            pass

        self.database.cursor.execute(
            "SELECT dob FROM people_person WHERE user_ptr_id='%s'" %
            str(user_id))
        try:
            for _ in self.database.cursor.fetchall():
                exist = True
                break
        except psycopg2.ProgrammingError:
            pass
        try:
            assert exist is False
            print_result('Delete User Succeed')
            self.result['Delete User'] = SUCCESS
        except AssertionError:
            print_error('Delete User Failed')
            self.result['Delete User'] = FAIL
Example #12
0
 def logout(self, redirect=True):
     toggle = self.driver.find_elements_by_xpath(
         '//a[@class="dropdown-toggle"]')[0]
     toggle.click()
     links = self.driver.find_elements_by_xpath(
         '//ul[@class="dropdown-menu"]/li/a')
     for link in links:
         if link.text == 'Logout':
             link.click()
     sleep(5)
     login = self.driver.find_element_by_id('login')
     try:
         assert self.driver.current_url == self.url
         assert login is not None
         if redirect:
             login.click()
         sleep(1)
         self.result['Valid Logout'] = SUCCESS
         print_result('Valid logout Succeed')
     except AssertionError:
         print_error('Logout raises an error')
         self.result['Valid Logout'] = FAIL
     sleep(1)
     print()
Example #13
0
 def wrapped(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except Error as error:
         print_error(str(error))
         exit(error.exit_code)
Example #14
0
File: signup.py Project: rolycg/bot
    def create_account(self):
        account_link = self.driver.find_element_by_xpath(
            '//a[@ui-sref="createAccount"]')
        self.driver.execute_script("arguments[0].click();", account_link)
        # account_link.click()
        sleep(2)
        try:
            assert self.driver.current_url == REGISTER_URL
            self.result['Creation link'] = SUCCESS
            print_result('Creation link Succeed')
        except AssertionError:
            self.result['Creation link'] = FAIL
            print_error('Creation link Failed')

        first_name = self.driver.find_element_by_id('firstName')
        self.fill_field(first_name, CREATED_FIRST_NAME)
        sleep(1)
        last_name = self.driver.find_element_by_xpath(
            '//input[@name="lastName"]')
        self.fill_field(last_name, CREATED_LAST_NAME)
        sleep(1)
        self.select_option('birthday-month', 'January')
        sleep(1)
        self.select_option('birthday-day', '01')
        sleep(1)
        self.select_option('birthday-year', '1980')
        sleep(1)
        email = self.driver.find_element_by_xpath('//input[@name="email"]')
        self.fill_field(email, CREATED_EMAIL)
        sleep(1)
        password = self.driver.find_element_by_xpath(
            '//input[@name="password"]')
        self.fill_field(password, CREATED_PASSWORD)
        sleep(1)
        username = self.driver.find_element_by_id('displayName')
        self.fill_field(username, CREATED_USERNAME)
        sleep(1)
        self.select_option('country', CREATED_SOURCE)
        sleep(1)
        rules = self.driver.find_element_by_xpath('//input[@name="rules"]')
        rules.click()
        sleep(2)
        submit = self.driver.find_element_by_id('create-login-bt')
        self.driver.execute_script("arguments[0].click();", submit)
        sleep(5)

        check = False
        username_links = self.driver.find_elements_by_xpath('//a[@href="#"]')
        for username_link in username_links:
            if username_link.text == CREATED_USERNAME:
                check = True
        try:
            assert self.driver.current_url == CONFIRM_URL
            assert check
            print_result('Create User Succeed')
            self.result['Create User'] = SUCCESS
        except AssertionError:
            print_result('Create User Failed')
            self.result['Create User'] = FAIL

        print()