Python selenium.webdriver.common.keys.Keys 模块,RETURN 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用selenium.webdriver.common.keys.Keys.RETURN

项目:kitaab_bot    作者:rajdeep1008    | 项目源码 | 文件源码
def download_book(url, name):
    chromedriver = '/home/rajdeep1008/Desktop/chromedriver'
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver = webdriver.Chrome(chromedriver)
    driver.get(url)
    link = driver.find_element_by_link_text(name)
    actionChains = ActionChains(driver)
    actionChains.context_click(link)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.RETURN)
    actionChains.perform()

    while True:
        if not os.path.isfile('/home/rajdeep1008/Downloads/' + name + '.pdf'):
            time.sleep(5)
        else:
            break
    driver.quit()

# download_book('http://it-ebooks.info/book/6719/', 'Android Studio Game Development')
项目:golem    作者:lucianopuccio    | 项目源码 | 文件源码
def press_key(element, key):
    """Press a given key in the element.
    Parameters:
    element : element
    key : value
    """
    step_message = 'Press key: {}'.format(key)
    execution.logger.info(step_message)
    _capture_or_add_step(step_message, execution.settings['screenshot_on_step'])
    webelement = get_browser().find(element)
    if key == 'RETURN' or key == 'ENTER':
        webelement.send_keys(Keys.RETURN)
    elif key == 'UP':
        webelement.send_keys(Keys.UP)
    elif key == 'DOWN':
        webelement.send_keys(Keys.DOWN)
    elif key == 'LEFT':
        webelement.send_keys(Keys.LEFT)
    elif key == 'RIGHT':
        webelement.send_keys(Keys.RIGHT)
    else:
        raise Exception('Key value {} is invalid'.format(key))
项目:PythonStudyCode    作者:TongTongX    | 项目源码 | 文件源码
def login():
    driver = webdriver.Firefox()

    driver.implicitly_wait(10)

    driver.get("https://www.facebook.com")
    driver.find_element_by_id('email').send_keys("email_address")
    driver.find_element_by_id('pass').send_keys("password")
    driver.find_element_by_id('u_0_n').click()

    '''
    time.sleep(1)
    print "------- login ---------"
    email = driver.find_element_by_id('email')
    email.send_keys("email_address")
    time.sleep(1)
    password = driver.find_element_by_id('pass')
    password.send_keys("password")
    time.sleep(1)
    password.send_keys(Keys.RETURN)
    time.sleep(2)
    driver.get("https://www.facebook.com")
    time.sleep(1)
    pickle.dump(driver.get_cookies(), open("cookies.pkl", "w"))
    '''
项目:kolla-kubernetes    作者:openstack    | 项目源码 | 文件源码
def setUp(self):
        self.driver = self.getDriver()
        print("Got driver")
        self.driver.get(os.environ["OS_HORIZON"])
        try:
            delay = 5
            element_present = EC.presence_of_element_located((By.NAME,
                                                              'username'))
            WebDriverWait(self.driver, delay).until(element_present)
            self.driver.title.index("Login - OpenStack Dashboard")
            elem = self.driver.find_element_by_name("username")
            elem.send_keys(os.environ["OS_USERNAME"])
            elem = self.driver.find_element_by_name("password")
            elem.send_keys(os.environ["OS_PASSWORD"])
            elem.send_keys(Keys.RETURN)
        except TimeoutException:
            print("Loading took too much time!")
            raise
        time.sleep(2)
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def netease():
    options = webdriver.ChromeOptions()
    options.add_argument(
        '--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36')
    driver = webdriver.Chrome(executable_path=r'C:\software\chrome\chromedriver.exe',
                              chrome_options=options)
    driver.implicitly_wait(40)
    driver.get("http://30daydo.com/")
    elem_user = driver.find_element_by_tag_name("??")
    elem_user.click()
    ''''
    elem_pwd = driver.find_element_by_name("password")
    elem_pwd.send_keys("123456")
    elem_pwd.send_keys(Keys.RETURN)
    '''
    time.sleep(5)
    assert "baidu" in driver.title
    driver.close()
    driver.quit()
项目:open-source-feeds    作者:mhfowler    | 项目源码 | 文件源码
def fb_login(self):
        """
        logs into facebook
        :return:
        """
        self.log('++ logging into facebook')
        self.driver.get("http://www.facebook.org")
        time.sleep(1)
        assert "Facebook" in self.driver.title
        elem = self.driver.find_element_by_id("email")
        elem.send_keys(self.fb_username)
        elem = self.driver.find_element_by_id("pass")
        elem.send_keys(self.fb_password)
        elem.send_keys(Keys.RETURN)
        time.sleep(3)
        self.assert_logged_in()
        self.log('++ successfully logged in')
        self.logged_in = True
项目:FaceNet    作者:dav-ell    | 项目源码 | 文件源码
def facebook_login(driver, username, password):
    print("\n\n\nLogin to Facebook...."),
    sys.stdout.flush()
    url = "http://www.facebook.com"
    driver.get(url)
    elem = driver.find_element_by_id("email")
    elem.send_keys(username)
    elem = driver.find_element_by_id("pass")
    elem.send_keys(password)
    elem.send_keys(Keys.RETURN)
    time.sleep(1)
    html_source = driver.page_source
    if "Please re-enter your password" in html_source or "Incorrect Email" in html_source:
        print(Fore.RED + "Incorrect Username or Password")
        driver.close()
        exit()
    else:
        print(Fore.GREEN + "Success\n")
    return driver.get_cookies()
项目:CIDDS    作者:markusring    | 项目源码 | 文件源码
def start_search(driver, keywords, var):
    try:
        # Determine the number of search terms and choose one randomly
        nb = file_len(keywords)
        rand = random.randint(1, nb)
        search = linecache.getline(keywords, rand)

        # Determine search field and enter search term
        elem = driver.find_element_by_name(var)
        elem.send_keys(search)
        elem.send_keys(Keys.RETURN)
        echoC(myName, "Searched: " + search)
        time.sleep(5)   
    except Exception as e:
        echoC(myName, "start_search() error: " + str(e))
        return -1
    return 0

# Click on a link based on the HTML tag name
项目:Opencv_learning    作者:wjb711    | 项目源码 | 文件源码
def test_search_in_python_org(self):
        driver = self.driver
        driver.get("http://t.cn/R9U4xwG")
        #self.assertIn("Python", driver.title)
        elem = driver.find_element_by_name("editor")
        #????????
        elem.send_keys("???????")
        #time.sleep(5)
        #elem.clear()
        #elem.send_keys(Keys.RETURN)
        #assert "No results found." not in driver.page_source
        ele=driver.find_element_by_tag_name("input")
        #<i class="icon-pic iconfont icon-mailbox_icon_addpic_1"></i>
        time.sleep(2)
        #ele.click()
        print ("done")
        #????????????
        ele.send_keys("C:\\CV\\Github\\Opencv_learning\\pic.jpg")
        time.sleep(15)
        driver.find_element_by_id("btnPreview").click()
项目:Opencv_learning    作者:wjb711    | 项目源码 | 文件源码
def test_search_in_python_org(self):
        driver = self.driver
        driver.get("http://t.cn/R9U4xwG")
        #self.assertIn("Python", driver.title)
        elem = driver.find_element_by_name("editor")
        #????????
        #elem.send_keys("???????")
        #time.sleep(5)
        #elem.clear()
        #elem.send_keys(Keys.RETURN)
        #assert "No results found." not in driver.page_source
        ele=driver.find_element_by_tag_name("input")
        #<i class="icon-pic iconfont icon-mailbox_icon_addpic_1"></i>
        time.sleep(2)
        #ele.click()
        print ("done")
        #????????????
        ele.send_keys("C:\\CV\\Github\\Opencv_learning\\face\\pic.jpg")
        time.sleep(5)
        driver.find_element_by_id("btnPreview").click()
项目:Opencv_learning    作者:wjb711    | 项目源码 | 文件源码
def miaomiao():
    driver.get("http://t.cn/R9U4xwG")
        #self.assertIn("Python", driver.title)
    elem = driver.find_element_by_name("editor")
    elem.send_keys("???????")
        #time.sleep(5)
        #elem.clear()
        #elem.send_keys(Keys.RETURN)
        #assert "No results found." not in driver.page_source
    ele=driver.find_element_by_tag_name("input")
        #<i class="icon-pic iconfont icon-mailbox_icon_addpic_1"></i>
    time.sleep(2)
        #ele.click()
    print ("done")
    ele.send_keys("C:\\CV\\Github\\Opencv_learning\\face\\pic.jpg")
    time.sleep(5)
    driver.find_element_by_id("btnPreview").click()
项目:Opencv_learning    作者:wjb711    | 项目源码 | 文件源码
def test_search_in_python_org(self):
        driver = self.driver
        driver.get("http://t.cn/R9U4xwG")
        #self.assertIn("Python", driver.title)
        elem = driver.find_element_by_name("editor")
        #????????
        #elem.send_keys("???????")
        #time.sleep(5)
        #elem.clear()
        #elem.send_keys(Keys.RETURN)
        #assert "No results found." not in driver.page_source
        ele=driver.find_element_by_tag_name("input")
        #<i class="icon-pic iconfont icon-mailbox_icon_addpic_1"></i>
        time.sleep(2)
        #ele.click()
        print ("done")
        #????????????
        ele.send_keys("C:\\CV\\Github\\Opencv_learning\\face\\pic.jpg")
        time.sleep(5)
        driver.find_element_by_id("btnPreview").click()
项目:Opencv_learning    作者:wjb711    | 项目源码 | 文件源码
def miaomiao():
    driver.get("http://t.cn/R9U4xwG")
        #self.assertIn("Python", driver.title)
    elem = driver.find_element_by_name("editor")
    elem.send_keys("???????")
        #time.sleep(5)
        #elem.clear()
        #elem.send_keys(Keys.RETURN)
        #assert "No results found." not in driver.page_source
    ele=driver.find_element_by_tag_name("input")
        #<i class="icon-pic iconfont icon-mailbox_icon_addpic_1"></i>
    time.sleep(2)
        #ele.click()
    print ("done")
    ele.send_keys("C:\\CV\\Github\\Opencv_learning\\face\\pic.jpg")
    time.sleep(3)
    driver.find_element_by_id("btnPreview").click()
    time.sleep(15)
项目:snowballing    作者:JoaoFelipe    | 项目源码 | 文件源码
def check_captcha(driver, condition):
    """ Check if it expects a captcha """
    captcha = driver.find_elements_by_css_selector("#captcha")
    captcha += driver.find_elements_by_css_selector("#gs_captcha_f")
    captcha += driver.find_elements_by_css_selector("#g-recaptcha")
    captcha += driver.find_elements_by_css_selector("#recaptcha")
    while captcha:
        print("Ops. It requires a captcha!")
        print("If you filled in the browser, type '<ok>' here.")
        inp = input("Captcha: ")
        if inp == "<ok>":
            break
        captcha[0].send_keys(inp)
        captcha[0].send_keys(Keys.RETURN)
        try:
            if condition:
                wait_for(driver, condition)
            break
        except TimeoutException:
            captcha = driver.find_elements_by_css_selector("#captcha")
项目:Browser-Automation    作者:dynamitechetan    | 项目源码 | 文件源码
def sendMessage(msg, recepient_list):
    for recep in recepient_list:
        print ("Sending to : ",recep)
        try:
            one_chat = driver.find_element_by_xpath("//span[@title='%s']"%(recep))
        except:
            print ("Unable to find username [%s]"%recep)
            continue
        if one_chat != None:
            try:
                one_chat.click()
                wait(1)
                print ("Chatbox opened for ", recep)
                text_box = driver.find_element_by_xpath("//div[@contenteditable='true']")
                for letter in list(msg):
                    text_box.send_keys(letter)
                    wait(0.1)
                text_box.send_keys(Keys.RETURN)
            except:
                print ("Unable to send msg [%s] to [%s]"%(msg, recep))
                continue
            print ("Message [%s] sent to [%s]"%(msg, recep))
项目:robotframework-weblibrary    作者:Netease-AutoTest    | 项目源码 | 文件源码
def _map_ascii_key_code_to_key(self, key_code):
        map = {
            0: Keys.NULL,
            8: Keys.BACK_SPACE,
            9: Keys.TAB,
            10: Keys.RETURN,
            13: Keys.ENTER,
            24: Keys.CANCEL,
            27: Keys.ESCAPE,
            32: Keys.SPACE,
            42: Keys.MULTIPLY,
            43: Keys.ADD,
            44: Keys.SEPARATOR,
            45: Keys.SUBTRACT,
            56: Keys.DECIMAL,
            57: Keys.DIVIDE,
            59: Keys.SEMICOLON,
            61: Keys.EQUALS,
            127: Keys.DELETE
        }
        key = map.get(key_code)
        if key is None:
            key = chr(key_code)
        return key
项目:Course-Page-Downloader    作者:kp96    | 项目源码 | 文件源码
def login(self):
        print "Loggin in"
        driver.get('https://vtop.vit.ac.in/student/stud_login.asp')
        time.sleep(0.5) # Let the user actually see something!
        regno_el = driver.find_element_by_name('regno')
        pwd_el = driver.find_element_by_name('passwd')
        regno_el.send_keys(self.regno)
        pwd_el.send_keys(self.pwd)
        pwd_el.send_keys(Keys.RETURN)
        time.sleep(1) # Let the user actually see something!
        soup = BeautifulSoup(driver.page_source, "html.parser")
        try:
            x = ((soup.findAll('table')[1]).td.font.string.split(" - "))[1]
            return x == self.regno
        except:
                return False
项目:linkedin-jobs-scraper    作者:kirkhunter    | 项目源码 | 文件源码
def login(self):
        """login to linkedin then wait 3 seconds for page to load"""
        # Enter login credentials
        WebDriverWait(self.driver, 120).until(
            EC.element_to_be_clickable(
                (By.ID, "session_key-login")
            )
        )
        elem = self.driver.find_element_by_id("session_key-login")
        elem.send_keys(self.username)
        elem = self.driver.find_element_by_id("session_password-login")
        elem.send_keys(self.password)
        # Enter credentials with Keys.RETURN
        elem.send_keys(Keys.RETURN)
        # Wait a few seconds for the page to load
        time.sleep(3)
项目:linkedin-jobs-scraper    作者:kirkhunter    | 项目源码 | 文件源码
def enter_search_keys(self):
        """
        execute the job search by entering job and location information.
        The location is pre-filled with text, so we must clear it before
        entering our search.
        """
        driver = self.driver
        WebDriverWait(driver, 120).until(
            EC.presence_of_element_located(
                (By.ID, "keyword-search-box")
            )
        )
        # Enter search criteria
        elem = driver.find_element_by_id("keyword-search-box")
        elem.send_keys(self.keyword)
        # clear the text in the location box then enter location
        elem = driver.find_element_by_id("location-search-box").clear()
        elem = driver.find_element_by_id("location-search-box")
        elem.send_keys(self.location)
        elem.send_keys(Keys.RETURN)
        time.sleep(3)
项目:instagram-followers-scraper    作者:frabonomi    | 项目源码 | 文件源码
def authenticate(self, username, password):
        """Log in to Instagram with the provided credentials."""

        print('\nLogging in…')
        self.driver.get('https://www.instagram.com')

        # Go to log in
        login_link = WebDriverWait(self.driver, 5).until(
            EC.presence_of_element_located((By.LINK_TEXT, 'Log in'))
        )
        login_link.click()

        # Authenticate
        username_input = self.driver.find_element_by_xpath(
            '//input[@placeholder="Username"]'
        )
        password_input = self.driver.find_element_by_xpath(
            '//input[@placeholder="Password"]'
        )

        username_input.send_keys(username)
        password_input.send_keys(password)
        password_input.send_keys(Keys.RETURN)
        time.sleep(1)
项目:winnaker    作者:target    | 项目源码 | 文件源码
def get_application(self, appname):
        self.check_page_contains_error()
        e = wait_for_xpath_presence(
            self.driver, cfg_applications_xpath, be_clickable=True)
        e.click()
        e = wait_for_xpath_presence(self.driver, cfg_searchbox_xpath)
        e.send_keys(appname)
        e.send_keys(Keys.RETURN)
        time.sleep(1)
        self.driver.save_screenshot(join(
            cfg_output_files_path,
            "applications.png"))
        app_xpath = "//a[contains (.,'" + appname + "')]"
        e = wait_for_xpath_presence(self.driver, app_xpath)
        e.click()
        time.sleep(1)
        logging.info("- Searched for application: {}".format(appname))
项目:archivematica-acceptance-tests    作者:artefactual-labs    | 项目源码 | 文件源码
def login(self):
        """Login to Archivematica."""
        self.driver.get(self.get_login_url())
        username_input_id = 'id_username'
        password_input_id = 'id_password'
        try:
            element_present = EC.presence_of_element_located(
                (By.ID, username_input_id))
            WebDriverWait(self.driver, self.timeout).until(element_present)
        except TimeoutException:
            print("Loading took too much time!")
        username_elem = self.driver.find_element_by_id(username_input_id)
        username_elem.send_keys(self.am_username)
        password_elem = self.driver.find_element_by_id(password_input_id)
        password_elem.send_keys(self.am_password)
        submit_button_elem = self.driver.find_element_by_tag_name('button')
        submit_button_elem.click()
        # submit_button_elem.send_keys(Keys.RETURN)
项目:insta-liker    作者:mohdomama    | 项目源码 | 文件源码
def login(username,password):
    print('logging in..')
    element = browser.find_element_by_name('username')
    element.clear()
    element.send_keys(username)

    element = browser.find_element_by_name('password')
    element.clear()
    element.send_keys(password)

    element.send_keys(Keys.RETURN)

    #check if the username and password are correct
    loginTime=time.time()
    while True:
        if browser.current_url=='https://www.instagram.com/':
            break
        elif time.time()-loginTime>10:                  #if login takes more than 10 seconds, tell user that his internet is slow
                print('Your Internet seems slow!\n',e)
                browser.close()
                sys.exit()
        else:
            try:
                element=browser.find_element_by_xpath("//*[@id='slfErrorAlert']")
                print('\n'+element.text)
                print('Enter your credentials again!\n')
                browser.close()
                main()
                sys.exit()
            except:
                #do nothing
                pass

    print('login complete')
项目:OS_FrontendMaster-dl    作者:li-xinyang    | 项目源码 | 文件源码
def login(self, id, password):
        self.browser.get(URL_LOG_IN)
        time.sleep(2)

        username_field = self.browser.find_element_by_id('username')
        password_field = self.browser.find_element_by_id('password')

        username_field.send_keys(id)
        password_field.send_keys(password)
        password_field.send_keys(Keys.RETURN)
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def test_1089(self):
        self.case_no = self.get_case_number()
        self.log.info(' CASE %s log: ' % str(self.case_no))
        self.driver.maximize_window()
        self.driver.get(self.base_url)
        self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
        self.driver.find_element_by_link_text('new-default-project').click()
        self.driver.find_element_by_id('change-machine-toggle').click()
        self.driver.find_element_by_id('machine-change-input').clear()
        self.driver.find_element_by_id('machine-change-input').send_keys('qemuarm64')
#        self.driver.find_element_by_id('machine-change-input').send_keys(Keys.RETURN)
        self.driver.find_element_by_id('machine-change-btn').click()
        con=sqlite.connect('toaster.sqlite')
        cursor = con.cursor()
        query = "select count(id) from orm_projectvariable where name like 'machine' and value like 'qemuarm64';"
        cursor.execute(query)
        data = cursor.fetchone()[0]
        self.failUnless(data == 1)
        #resetting machine to default value
        self.driver.find_element_by_id('change-machine-toggle').click()
        self.driver.find_element_by_id('machine-change-input').clear()
        self.driver.find_element_by_id('machine-change-input').send_keys('qemux86')
        self.driver.find_element_by_id('machine-change-input').send_keys(Keys.RETURN)
        self.driver.find_element_by_id('machine-change-btn').click()

        ##############
        #  CASE 1090 #
        ##############
项目:Instagram-Brute-Forcer    作者:The404Hacking    | 项目源码 | 文件源码
def login(user, password, delay):
    try:
        print 'Trying with password: ' + password
        elem = driver.find_element_by_name("username")
        elem.clear()
        elem.send_keys(user)
        elem = driver.find_element_by_name("password")
        elem.clear()
        elem.send_keys(password)  
        elem.send_keys(Keys.RETURN)
        sleep(delay)
        assert (("Login") in driver.title)
        #assert (("Your username or password was incorrect" or "son incorrectos.") not in driver.page_source)
        #if driver.current_url == 'https://www.instagram.com/':
        #   print 'Password correct!'
        #   print '%s' %password
        #else:
        #   print 'Wrong password'
    except AssertionError:
        print 'Access granted mother kaker!!' 
        print 'The password is: ' + password
        try:
            f = open('pwnedAccounts.txt','a')
        except:
            f = open('pwnedAccounts.txt','w')
        f.write('username:'+user+'\npassword:'+password+'\n')
        f.close()
        driver.delete_all_cookies()
        return 1
    except:
        print "\r Check your connection to the internet mother kaker\r"
项目:bank_wrangler    作者:tmerr    | 项目源码 | 文件源码
def fetch(config, fileobj):
    user, password = config

    # use the user's regular firefox profile instead of a fresh temporary one.
    # this is to avoid getting fingerprinted as a new device which generates
    # annoying emails and asks for additional info. luckily this profile is
    # cloned into a temporary directory, so we can change preferences without
    # affecting the original copy.
    profile = FirefoxProfile(_firefox_default_profile())
    # disable a json viewer that's enabled by default in firefox 53+.
    profile.set_preference('devtools.jsonview.enabled', False)
    driver = Firefox(profile)

    driver.get('https://venmo.com/account/sign-in/')
    user_elem = driver.find_element_by_name('phoneEmailUsername')
    user_elem.clear()
    user_elem.send_keys(user.value)
    password_elem = driver.find_element_by_name('password')
    password_elem.clear()
    password_elem.send_keys(password.value)
    password_elem.send_keys(Keys.RETURN)

    WebDriverWait(driver, 15).until(title_contains('Welcome'))

    params = '?start_date=2009-01-01&end_date={}-01-01'.format(datetime.now().year + 1)
    url = 'https://api.venmo.com/v1/transaction-history' + params
    driver.get(url)

    # validate json and raise ValueError on failure.
    pre = driver.find_element_by_tag_name('pre').text
    json.loads(pre)

    driver.quit()
    fileobj.write('{}\n'.format(user.value))
    fileobj.write(pre)
项目:bank_wrangler    作者:tmerr    | 项目源码 | 文件源码
def _download(config, tempdir):
    cfg_user, cfg_pass, *cfg_security = config

    driver = FirefoxDownloadDriver(tempdir, 'application/binary')
    driver.get('https://www.citizensbankonline.com/efs/servlet/efs/login.jsp')

    # Sign in
    user = driver.find_element_by_id('UserID')
    user.clear()
    user.send_keys(cfg_user.value)
    password = driver.find_element_by_id('currentpassword')
    password.clear()
    password.send_keys(cfg_pass.value)
    password.send_keys(Keys.RETURN)

    # Set an implicit wait (which defaults to 0) to save us from
    # accessing elements before they are ready.
    driver.implicitly_wait(30)

    # Switch into the AJAX-created frame that contains the security question
    # then answer it.
    driver.switch_to.frame(driver.find_element_by_name('mainFrame'))
    question_elem = driver.find_element_by_xpath("//label[@for='Response']")
    answer_elem = driver.find_element_by_id('Response')
    answer = _answer_security_question(question_elem.text, cfg_security)
    answer_elem.send_keys(answer)
    answer_elem.send_keys(Keys.RETURN)

    balances = _read_balances(driver)

    # Click "Download transactions", set options, and download.
    download_elem = driver.find_element_by_class_name('account-transactions-download')
    download_elem.click()
    driver.find_element_by_xpath('.//option[normalize-space(.) = "All Dates"]').click()
    driver.find_element_by_xpath('.//option[normalize-space(.) = "Comma Delimited"]').click()
    # Selenium sometimes misclicks the download button, so just call its onclick javascript.
    driver.execute_script('setFilterValues()')
    csv_path = driver.grab_download('EXPORT.CSV', timeout_seconds=30)

    driver.quit()
    return csv_path, balances
项目:chat-bots-manager    作者:toxtli    | 项目源码 | 文件源码
def pressEnter(self, fieldObject):
        fieldObject.send_keys(Keys.RETURN)
        return fieldObject
项目:i_love_python    作者:MayankPratap    | 项目源码 | 文件源码
def test_search_in_python_org(self):
        driver=self.driver
        driver.get("http://www.python.org")
        self.assertIn("Python",driver.title)
        elem=driver.find_element_by_name("q")
        elem.send_keys("pycon")
        elem.send_keys(Keys.RETURN)
        assert "No results found. " not in driver.page_source
项目:Py    作者:LockGit    | 项目源码 | 文件源码
def test_lock(self):
        driver = self.driver
        driver.get("http://www.baidu.com")
        self.assertIn(u"????", driver.title)
        elem = driver.find_element_by_id("kw")
        elem.send_keys("lock")
        elem.send_keys(Keys.RETURN)
        i = 0
        while 1:
               if i>=2:
                    break
               time.sleep(1)
               i+=1
               print "not test %s , wait %s second continue ..." % ('lock',i,)
项目:Py    作者:LockGit    | 项目源码 | 文件源码
def test_search(self):
        driver = self.driver
        driver.get("http://www.baidu.com")
        self.assertIn(u"????", driver.title)
        elem = driver.find_element_by_id("kw")
        elem.send_keys("php")
        elem.send_keys(Keys.RETURN)
        i = 0
        while 1:
               if i>=2:
                    break
               time.sleep(1)
               i+=1
               print "not test %s , wait %s second continue ..." % ('php',i,)
        assert "No results found." not in driver.page_source
项目:WebAutomaiton    作者:AlvinXuCH    | 项目源码 | 文件源码
def enter(self,element):
        '''
        Keyboard: hit return

        Usage:
        self.enter(element)
        '''
        element.send_keys(Keys.RETURN)
项目:instagram_sifre_kirma    作者:turksiberguvenlik    | 项目源码 | 文件源码
def login(user, password, delay):
    try:
        print 'Trying with password: ' + password
        elem = driver.find_element_by_name("username")
        elem.clear()
        elem.send_keys(user)
        elem = driver.find_element_by_name("password")
        elem.clear()
        elem.send_keys(password)  
        elem.send_keys(Keys.RETURN)
        sleep(delay)
        assert (("Login") in driver.title)
        #assert (("Your username or password was incorrect" or "son incorrectos.") not in driver.page_source)
        #if driver.current_url == 'https://www.instagram.com/':
        #   print 'Password correct!'
        #   print '%s' %password
        #else:
        #   print 'Wrong password'
    except AssertionError:
        print 'Access granted mother kaker!!' 
        print 'The password is: ' + password
        try:
            f = open('pwnedAccounts.txt','a')
        except:
            f = open('pwnedAccounts.txt','w')
        f.write('username:'+user+'\npassword:'+password+'\n')
        f.close()
        driver.delete_all_cookies()
        return 1
    except:
        print "\r Check your connection to the internet mother kaker\r"
项目:marvin    作者:sdss    | 项目源码 | 文件源码
def test_search(self, search_page):
        assert search_page.results is None
        search_page.searchbox = 'nsa.z < 0.1'
        search_page.searchbox = Keys.RETURN
        assert search_page.results is not None
        assert search_page.table is not None
项目:facebook-bulk-group-inviter    作者:danielireson    | 项目源码 | 文件源码
def import_members(self, emails):
    print('Attempting to import email addresses')
    input_xpath = "//input[@placeholder='Enter name or email address...']"
    add_members_field = self.browser.find_element_by_xpath(input_xpath)
    for email in emails:
      for c in email:
        add_members_field.send_keys(self._get_base_character(c))
      add_members_field.send_keys(Keys.RETURN)
      time.sleep(random.randint(1,self.delay))
项目:lectureDL    作者:larryhudson    | 项目源码 | 文件源码
def lms_login(parent, user, password):
    user_field = parent.find_element_by_css_selector('input[name=user_id]')
    user_field.send_keys(user)
    pass_field = parent.find_element_by_css_selector('input[name=password]')
    pass_field.send_keys(password)
    pass_field.send_keys(Keys.RETURN)
项目:nextcloud    作者:syncloud    | 项目源码 | 文件源码
def test_main(driver, user_domain):

    user = driver.find_element_by_id("user")
    user.send_keys(DEVICE_USER)
    password = driver.find_element_by_id("password")
    password.send_keys(DEVICE_PASSWORD)
    driver.get_screenshot_as_file(join(screenshot_dir, 'login.png'))
    # print(driver.page_source.encode('utf-8'))

    password.send_keys(Keys.RETURN)
    driver.get_screenshot_as_file(join(screenshot_dir, 'login_progress.png'))
    #time.sleep(30)
    #driver.get_screenshot_as_file(join(screenshot_dir, 'login_progress_2.png'))

    # try:
    #     password.submit()
    # except WebDriverException, e:
    #     if 'submit is not a function' in e.msg:
    #         print("https://github.com/SeleniumHQ/selenium/issues/3483")
    #         print(e)
    #         pass
    #     else:
    #         raise e
    # time.sleep(5)
    #

    wait_driver = WebDriverWait(driver, 120)
    #wait_driver.until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, '#header #expandDisplayName'), DEVICE_USER))

    wait_driver.until(EC.element_to_be_clickable((By.ID, 'closeWizard')))
    wizard_close_button = driver.find_element_by_id("closeWizard")
    wizard_close_button.click()

    time.sleep(2)
    driver.get_screenshot_as_file(join(screenshot_dir, 'main.png'))
项目:python-selenium-seed    作者:zealzhangz    | 项目源码 | 文件源码
def login(self):
        self.driver = webdriver.Chrome(self.driverPath)
        self.wait = WebDriverWait(self.driver, self.waitSeconds)
        self.driver.get(self.loginUrl)
        phone = self.wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='login_field']")))
        passwd = self.wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='password']")))
        loginbtn = self.wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='login']/form/div[4]/input[3]")))

        phone.send_keys(Settings.USER_NAME)
        passwd.send_keys(Settings.PASSWD)
        loginbtn.send_keys(Keys.RETURN)
项目:wswp    作者:kjam    | 项目源码 | 文件源码
def login(driver):
    driver.get(LOGIN_URL)
    driver.find_element_by_id('auth_user_email').send_keys(LOGIN_EMAIL)
    driver.find_element_by_id('auth_user_password').send_keys(
        LOGIN_PASSWORD + Keys.RETURN)
    pg_loaded = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "results")))
    assert 'login' not in driver.current_url
项目:Browser-Automation    作者:dynamitechetan    | 项目源码 | 文件源码
def test_login(self):
        driver = self.driver

        usr = "rollNumberPleaseReplace"
        pwd = "PASSWORD"
        driver = webdriver.Chrome("D:\chromedriver\chromedriver")
        # or you can use Chrome(executable_path="/usr/bin/chromedriver")
        driver.get("http://punjab.chitkara.edu.in//Interface/index.php")
        assert "Chalkpad" in driver.title
        elem = driver.find_element_by_id("username")
        elem.send_keys(usr)
        elem = driver.find_element_by_id("password")
        elem.send_keys(pwd)
        elem.send_keys(Keys.RETURN)
        self.assertTrue(driver.find_element_by_link_text("Logout"),"Logout link")
项目:spider    作者:luanxiangming    | 项目源码 | 文件源码
def enter(self, element):
        """
        Keyboard: hit return

        Usage:
        self.enter(element)
        """
        element.send_keys(Keys.RETURN)
项目:spider    作者:luanxiangming    | 项目源码 | 文件源码
def authenticate(self):
        username_login = self.wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,
                                                                     'body > div.login-wrap > div > div > div > div > div.login-tabWrap.clearBoth > div:nth-child(2) > a')))
        username_login.click()
        username = self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, '#userNameLogin'))
        )
        password = self.wait.until(EC.presence_of_element_located(
            (By.CSS_SELECTOR, '#pwd')))
        username.clear()
        username.send_keys(auth.LU_USER)
        password.clear()
        password.send_keys(auth.LU_PASS)
        password.send_keys(Keys.RETURN)
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def test_teacher_select_when_to_show_feedback_to_a_student_8054(self):
        """Select when to show feedback to a student.

        Steps:
        From the dashboard, click on the 'Add assignment' drop down menu
        Click on the 'Add Homework' button
        Select an option on the 'Show feedback' drop down menu

        Expected Result:
        The option chosen is shown on the drop down menu.
        """
        self.ps.test_updates['name'] = 't1.16.027' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.16', 't1.16.027', '8054']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        Assignment().open_assignment_menu(self.teacher.driver)
        self.teacher.driver.find_element(By.LINK_TEXT, 'Add Homework').click()
        assert('homework/new' in self.teacher.current_url()), \
            'Not on the add a homework page'
        self.teacher.wait.until(
            expect.presence_of_element_located(
                (By.ID, "feedback-select")
            )
        ).send_keys("instantly" + Keys.RETURN)

        self.ps.test_updates['passed'] = True

    # Case C8055 - 028 - Teacher | Change when to show feedback for draft hw
项目:test-automation    作者:openstax    | 项目源码 | 文件源码
def test_content_reviewer_log_into_exercises_96962(self):
        """Log into Exercises.

        Steps:
        Go to https://exercises-qa.openstax.org/
        Click "SIGN IN"
        Enter the Content username into "Email or username" text box
        Click "Next"
        Enter the Content password into "password" text box
        Click "Login"

        Expected Result:
        User is logged in
        """
        self.ps.test_updates['name'] = 't1.36.012' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.012', '96962']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.content.driver.get("https://exercises-qa.openstax.org/")
        self.content.sleep(3)

        self.content.find(By.LINK_TEXT, "SIGN IN").click()
        self.content.find(By.XPATH, "//input[@id='login_username_or_email']") \
            .send_keys(os.getenv('CONTENT_USER'))
        self.content.find(By.XPATH, "//input[@id='login_username_or_email']") \
            .send_keys(Keys.RETURN)
        self.content.sleep(2)

        self.content.find(By.XPATH, "//input[@id='login_password']") \
            .send_keys(os.getenv('CONTENT_PASSWORD'))
        self.content.find(By.XPATH, "//input[@id='login_password']") \
            .send_keys(Keys.RETURN)
        self.content.sleep(3)

        self.content.find(By.LINK_TEXT, "SIGN OUT")

        self.ps.test_updates['passed'] = True

    # Case C96963 - 013 - Content Reviewer | Access Reviewer Display
项目:facebook-automation    作者:sjsafranek    | 项目源码 | 文件源码
def happy_birthdays(self):
        self.browser.get('https://www.facebook.com/events/birthdays')
        div = self.browser.find_element(By.ID,"events_birthday_view")
        text_areas = div.find_elements(By.CSS_SELECTOR,"textarea.enter_submit.uiTextareaNoResize.uiTextareaAutogrow.uiStreamInlineTextarea.inlineReplyTextArea.mentionsTextarea.textInput")
        for textarea in text_areas:
            textarea.send_keys("HAPPY BIRTHDAY!!" + Keys.RETURN)
项目:alma-slipsomat    作者:scriptotek    | 项目源码 | 文件源码
def connect(self):
        domain = self.config.get('login', 'domain')
        auth_type = self.config.get('login', 'auth_type')
        institution = self.config.get('login', 'institution')
        username = self.config.get('login', 'username')
        password = self.config.get('login', 'password')

        self.driver = self.get_driver()
        self.driver.set_window_size(self.config.get('window', 'width'),
                                    self.config.get('window', 'height'))
        self.wait = self.waiter()

        print('Opening instance {}:{}'.format(self.instance, institution))

        self.get('/mng/login?institute={}&auth={}'.format(institution, auth_type))

        if auth_type == 'SAML' and domain != '':
            print('Logging in as {}@{}'.format(username, domain))

            element = self.wait.until(EC.visibility_of_element_located((By.ID, 'org')))
            select = Select(element)
            select.select_by_value(domain)

            element = self.driver.find_element_by_id('submit')
            element.click()
            # We cannot use submit() because of
            # http://stackoverflow.com/questions/833032/submit-is-not-a-function-error-in-javascript
        else:
            print('Logging in as {}'.format(username))

        self.send_keys(By.ID, 'username', username)
        element = self.send_keys(By.ID, 'password', password)
        element.send_keys(Keys.RETURN)

        try:
            # Look for some known element on the Alma main screen
            self.wait_for(By.CSS_SELECTOR, '.logoAlma', 30)
        except NoSuchElementException:
            raise Exception('Failed to login to Alma')

        print("login DONE")
项目:alma-slipsomat    作者:scriptotek    | 项目源码 | 文件源码
def scroll_into_view_and_click(self, value, by=By.ID):
        element = self.table.browser.driver.find_element(by, value)
        self.table.browser.driver.execute_script('arguments[0].scrollIntoView();', element);
        # Need to scroll a little bit more because of the fixed header
        self.table.browser.driver.execute_script('window.scroll(window.scrollX, window.scrollY-400)')
        element = self.wait.until(EC.element_to_be_clickable((by, value)))
        try:
            element.click()
        except:
            element.send_keys(Keys.RETURN)  # works in some edge cases
项目:timestrap    作者:overshard    | 项目源码 | 文件源码
def select2Select(self, id, value):
        """Select a value in a select2 menu. The select element *must* have an
        id attribute in order for this work. Select2 uses the select element id
        to create its container for selections.
        """
        selector = '#select2-' + id + '-container + .select2-selection__arrow'
        self.waitForClickable((By.CSS_SELECTOR, selector))
        self.find(By.CSS_SELECTOR, selector).click()
        field = self.waitForPresence((By.CLASS_NAME, 'select2-search__field'))
        field.send_keys(value)
        field.send_keys(Keys.RETURN)