python类ENTER的实例源码

Safe.py 文件源码 项目:myautotest 作者: auuppp 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def keypair(self,cloud_controller_name):
        Cloud_DebugLog.stepinfo(Messages.LOGIN_CLOUD) #"Login cloud"
        Cloud_client_browser = self.driver

        # :???????? Login and pass in with username, password, server and port
        self.admin_cloud_login(username='admin')
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)


        Cloud_DebugLog.stepinfo(Messages.CLICK_SET)
        Cloud_DebugLog.debug_print(Messages.CLICK_SET)
        Cloud_browser_main_map = Main_Browser_UIMap(Cloud_client_browser)
        openstatus=Cloud_client_browser.find_element_by_xpath("//span[text()='??']/../..").get_attribute("class")
        if openstatus=='open':
            pass
        else:

            safe_menu_btn=Cloud_browser_main_map.get_menu('security/')
            safe_menu_btn.click()
        safe_map=Safe_UIMap(Cloud_client_browser)
        safe_map.getelement("//span[text()='???']").click()
        time.sleep(1)
        safe_map.getelement("//*[@id='create_keypair']").click()
        time.sleep(1)
        keypairname='gyp'+"".join(random.sample('1234567890zyxwvutsrqponmlkjihgfedcba',5))
        safe_map.getelement("//*[@id='modal_style']/div/div[2]/div/div/div[1]/input").send_keys(keypairname)     
        safe_map.get_select(cloud_controller_name,name='cloud_controller_id')
        safe_map.getelement(id='id_button_submit').click()
        time.sleep(5)
        #safe_map.getelement("//*[@id='product-page']/div/h3").send_keys(Keys.ENTER)

        h3=safe_map.getelement("//*[@id='product-page']/div/h3").text
        a="???\""+keypairname+"\"??????????????????"
        assert h3==a
memedensity.py 文件源码 项目:Python-Scripts 作者: Logan1x 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _execute_script(email, password, count):


    print("\nLoading..\nCheck out today's xkcd comic till then : %s \n\n" %(_xkcd()))

    driver = webdriver.PhantomJS()
    driver.get('https://www.facebook.com')

    email_ID = driver.find_element_by_id('email')
    pass_ID = driver.find_element_by_id('pass')


    email_ID.send_keys(email)
    pass_ID.send_keys(password)
    pass_ID.send_keys(Keys.ENTER)
    sleep(5)

    for i in range(0,count):
        driver.execute_script("window.scrollBy(0, document.body.scrollHeight);")
        sleep(1)

    sleep(5)

    driver_tags = driver.execute_script('return document.getElementsByClassName("scaledImageFitWidth img")')

    driver_img_list = {
    'src' : [x.get_attribute('src') for x in driver_tags],
    'alt' : [x.get_attribute('alt') for x in driver_tags],
    }

    driver.quit()

    return driver_img_list
test_castalio.py 文件源码 项目:playground 作者: CastalioPodcast 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_castalio(self):
        driver = self.driver
        driver.get("http://castalio.info/")
        driver.find_element_by_id("tipue_search_input").send_keys("6 anos")
        driver.find_element_by_id("tipue_search_input").send_keys(Keys.ENTER)
        driver.find_element_by_link_text(u"Episódio 88: Episódio Especial de 6 Anos").click()
        self.assertEqual(u"Episódio 88: Episódio Especial de 6 Anos - Castálio Podcast", driver.title)
test_list_item_validation.py 文件源码 项目:superlists.ir 作者: aaghamohammadi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_cannot_add_empty_list_items(self):

        # Edith goes to the home page and accidentally tries to submit
        # an empty list item. She hits Enter on the empty input box
        self.browser.get(self.live_server_url)
        self.get_item_input_box().send_keys(Keys.ENTER)
        # The browser intercepts the request, and does not load the
        # list page
        self.wait_for(lambda: self.browser.find_elements_by_css_selector('#id_text:invalid'))  
        # She starts typing some text for the new item and the error disappears
        self.get_item_input_box().send_keys('Buy milk')
        self.wait_for(lambda: self.browser.find_elements_by_css_selector('#id_text:valid'))
        # And she can submit it successfully
        self.get_item_input_box().send_keys(Keys.ENTER)
        self.wait_for_row_in_list_table('1: Buy milk')
        # Perversely, she now decides to submit a second blank list item
        self.get_item_input_box().send_keys(Keys.ENTER)
        # Again, the browser will not comply
        self.wait_for_row_in_list_table('1: Buy milk')
        self.wait_for(lambda: self.browser.find_elements_by_css_selector('#id_text:invalid'))
        # And she can correct it by filling some text in
        self.get_item_input_box().send_keys('Make tea') 
        self.wait_for(lambda: self.browser.find_elements_by_css_selector('#id_text:valid'))
        self.get_item_input_box().send_keys(Keys.ENTER)
        self.wait_for_row_in_list_table('1: Buy milk')
        self.wait_for_row_in_list_table('2: Make tea')
weixin_action.py 文件源码 项目:Opencv_learning 作者: wjb711 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test(name,chat):
    print ('ok here')
    #elem = weixin_main.driver.find_element_by_name("editor")
    #elem = weixin_main.driver.find_element_by_class_name("web_wechat_search")
    friend_name = weixin_main.driver.find_element_by_tag_name("input")
    #elem.click()
    friend_name.send_keys(name)
    time.sleep(3)
    friend_name.send_keys(Keys.ENTER)
    chat_content = weixin_main.driver.find_element_by_id("editArea")
    time.sleep(1)
    chat_content.send_keys(chat)
    #elem.send_keys(Keys.ENTER)
    print ('ok here1')
weixin_action1.py 文件源码 项目:Opencv_learning 作者: wjb711 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test(name,chat):
    print ('ok here')
    #elem = weixin_main.driver.find_element_by_name("editor")
    #elem = weixin_main.driver.find_element_by_class_name("web_wechat_search")
    friend_name = weixin_main.driver.find_element_by_tag_name("input")
    #elem.click()
    friend_name.send_keys(name)
    time.sleep(3)
    friend_name.send_keys(Keys.ENTER)
    chat_content = weixin_main.driver.find_element_by_id("editArea")
    time.sleep(1)
    chat_content.send_keys(chat)
    #elem.send_keys(Keys.ENTER)
    print ('ok here1')
weixin_action.py 文件源码 项目:Opencv_learning 作者: wjb711 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test(name,chat):
    print ('hello011')
    #????
    timedelta=datetime.timedelta(minutes=5)
    #?????
    now = str(datetime.datetime.now())[:-7]
    next=now
    #???????????,?????????????

    while True:
        print ('hello012')
        now = str(datetime.datetime.now())[:-7]
        if now==next:
            #print (sched_time)
            next=str(datetime.datetime.now()+timedelta)[:-7]
            #print (sched_time)
            print ('??????????')
            chat=???????.main()
            print ('abc is ',chat)
                #elem = weixin_main.driver.find_element_by_name("editor")
            #elem = weixin_main.driver.find_element_by_class_name("web_wechat_search")
            friend_name = weixin_main.driver.find_element_by_tag_name("input")
            #elem.click()
            friend_name.send_keys(name)
            time.sleep(3)
            friend_name.send_keys(Keys.ENTER)
            chat_content = weixin_main.driver.find_element_by_id("editArea")
            time.sleep(1)
            chat_content.send_keys(chat)
            time.sleep(2)
        time.sleep(1)
    #chat_content.send_keys(Keys.ENTER)
    #elem.send_keys(Keys.ENTER)
    print ('ok here1')

    print ('ok here')
pages.py 文件源码 项目:pyvideo 作者: pyvideo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def search(self, phrase):
        """
        Enter a search phrase and display the results
        """
        selector = 'input.gsc-input'
        self.wait_for_element_visibility(selector, 'Search input available')
        self.q(css=selector).fill(phrase + Keys.ENTER)
        self.wait_for_element_visibility('.gsc-results', 'Search results shown')
header.py 文件源码 项目:directory-tests 作者: uktrade 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def should_see_link_to(driver: webdriver, section: str, item_name: str):
    item_selector = SECTIONS[section.lower()][item_name.lower()]
    if section.lower() in ["export readiness", "guidance", "services"]:
        logging.debug("Open the menu by sending 'Right Arrow' key")
        menu_selector = SECTIONS[section.lower()]["menu"]
        menu = find_element(driver, by_css=menu_selector)
        menu.send_keys(Keys.ENTER)
    menu_item = find_element(driver, by_css=item_selector)
    wait_for_visibility(driver, by_css=item_selector)
    with assertion_msg(
            "It looks like '%s' in '%s' section is not visible", item_name,
            section):
        assert menu_item.is_displayed()
jd_spider.py 文件源码 项目:pyCreeper 作者: ZcyAndWt 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def start_requests(self):
        def _search(driver):
            driver.find_element_by_id('key').send_keys(u"?????", Keys.ENTER)
            gevent.sleep(3)
            self._jump_guide(driver)
            gevent.sleep(3)

        yield Request(url='https://www.jd.com/',
                      meta={"cookiejar": "jd"},
                      callback=self.parse_list,
                      dynamic=True,
                      browser_actions=[_search]
                      )
waiter.py 文件源码 项目:explicit 作者: levi-rs 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def find_write(driver, elem_path, write_str, clear_first=True, send_enter=False,
               by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
    """ Find a writable element and write to it

    find_write locates a writable element on the page, waiting
    for up to timeout seconds. Once found, it writes the string
    to it.

    Args:
        driver (selenium webdriver or element): A driver or element
        elem_path (str): String used to located the element
        write_str (str): String to write
        clear_first (bool): Clear the contents before writing (default True)
        send_enter (bool): Send a keyboard ENTER after writing string
        by (selenium By): Selenium By reference
        timeout (int): Selenium Wait timeout, in seconds
        poll_frequency (float): Selenium Wait polling frequency, in seconds

    Returns:
        element: Selenium element

    Raises:
        TimeoutException: Raised when target element isn't located
    """
    elem = find_element(driver, elem_path=elem_path, by=by, timeout=timeout,
                        poll_frequency=poll_frequency)

    if clear_first:
        elem.clear()

    elem.send_keys(write_str)

    if send_enter:
        elem.send_keys(Keys.ENTER)

    return elem
tests.py 文件源码 项目:donation-system 作者: amigosdapoli 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_can_enter_donation_form_and_execute_donation(self):
        # Donor has heard about the opportunity to donate to the organization and enters the website
        self.browser.get(self.live_server_url)

        self.fill_in_donation_fields_right()
        self.fill_in_personal_fields_right()
        self.fill_in_cc_fields("4111111111111111")

        # Submit
        submit = self.browser.find_element_by_name("subbtn")
        submit.send_keys(Keys.ENTER)

        self.wait_for(lambda: self.assertIn('Muito obrigado pela sua doação!', self.browser.page_source))
tests.py 文件源码 项目:donation-system 作者: amigosdapoli 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_donor_fills_wrong_credit_card_and_gets_error(self):
        # Donor has heard about the opportunity to donate to the organization and enters the website
        self.browser.get(self.live_server_url)

        self.fill_in_donation_fields_right()
        self.fill_in_personal_fields_right()
        self.fill_in_cc_fields("4111111111111112")

        # Submit
        submit = self.browser.find_element_by_name("subbtn")
        submit.send_keys(Keys.ENTER)

        self.wait_for(lambda: self.assertIn('Erro nas informações de cartão de crédito enviadas.', self.browser.page_source))
cunyenrollment.py 文件源码 项目:CUNYFirst-Enrollment-Bot 作者: Maxthecoder1 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self):
        '''change these variables to fit your needs'''
        '''Go to twilio.com and create a free account'''
        self.accountsid =  '??????????'                # accountsid for twilio account, required to receive texts
        self.authtoken =   '??????????'                # authtoken for twilio account, required to receive texts
        self.mycellphone = '??????????'                # your cell phone number
        self.twiliocell =  '??????????'                # twilio cellnumber that will be used to send texts to your actual phone
        self.username =    '??????????'                # CUNYFIRST USERNAME
        self.password =    '??????????'                # CUNYFIRST PASSWORD
        '''In order to receive an email you must go myaccount.google.com/security and scroll all the way to he bottom.
           Then go to where it says 'Allow less secure apps: ON' and check OFF. You should get an email about the change '''
        self.gmailuser =   '??????????'               # GMAIL USER
        self.gmailpass =   '??????????'               # GMAIL PASSWORD
        self.recipient =   '??????????'               # Recipient email address (most likely your email)
        self.interval = 60                            # refresh interval in seconds

        '''Add shopping cart link is very important to this script. Go to CUNYFIRST, Click Enroll. Then choose your Term.
           Once you are are on the Shopping Cart Page, Right + Click on 'add' and Click on 'Copy Link Location'.
           Then copy and paste in here with single quotes. It should look like the link below'''
        self.addshoppingcartlink = 'https://hrsa.cunyfirst.cuny.edu/psc/cnyhcprd/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SSR_SSENRL_CART.GBL?Page=SSR_SSENRL_CART&Action=A&ACAD_CAREER=UGRD&EMPLID=12345678&ENRL_REQUEST_ID=&INSTITUTION=BKL01&STRM=1172'

        print("Starting Firefox and heading to CUNYFIRST")
        self.driver = webdriver.PhantomJS()
        self.driver.get('https://home.cunyfirst.cuny.edu')
        login = WebDriverWait(self.driver, timeout=30).until(
            EC.presence_of_element_located((By.NAME, "login")))
        login.send_keys(self.username)
        passs = self.driver.find_element_by_name("password")
        passs.send_keys(self.password, Keys.ENTER)
        studentcenter = WebDriverWait(self.driver, timeout=30).until(
            EC.presence_of_element_located((By.LINK_TEXT, "Student Center")))
        studentcenter.click()
        self.driver.get(self.addshoppingcartlink)
        shoppingcartlen = len(self.driver.find_elements_by_xpath("//table[@id='SSR_REGFORM_VW$scroll$0']/tbody/tr")) - 2
        self.shoppingcart = {}
        for i in range(0, shoppingcartlen):
            classname = self.driver.find_element_by_id("win0divP_CLASS_NAME$" + str(i)).text
            print(classname)
            status = self.driver.find_element_by_xpath(
                "//div[@id='win0divDERIVED_REGFRM1_SSR_STATUS_LONG$" + str(i) + "']/div/img").get_attribute('alt')
            self.shoppingcart[classname] = status
command_line.py 文件源码 项目:MemeDensity 作者: kalbhor 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def _execute_script(email, password, count):


    print("\nLoading..\nCheck out today's xkcd comic till then : %s \n\n" %(_xkcd()))

    driver = webdriver.PhantomJS()
    driver.get('https://www.facebook.com')

    email_ID = driver.find_element_by_id('email')
    pass_ID = driver.find_element_by_id('pass')


    email_ID.send_keys(email)
    pass_ID.send_keys(password)
    pass_ID.send_keys(Keys.ENTER)
    sleep(5)

    for i in range(0,count):
        driver.execute_script("window.scrollBy(0, document.body.scrollHeight);")
        sleep(1)

    sleep(5)

    driver_tags = driver.execute_script('return document.getElementsByClassName("scaledImageFitWidth img")')

    driver_img_list = {
    'src' : [x.get_attribute('src') for x in driver_tags],
    'alt' : [x.get_attribute('alt') for x in driver_tags],
    }

    driver.quit()

    return driver_img_list
bot.py 文件源码 项目:lichess-cheatbot 作者: plzb0ss 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def login_to_lichess(username, password):
    # login to Lichess
    chrome.get('https://en.lichess.org/login')
    login = chrome.find_element_by_id('username')
    login.send_keys(username)
    passwordField = chrome.find_element_by_id('password')
    passwordField.send_keys(password)
    passwordField.send_keys(Keys.ENTER)
PostToFacebook.py 文件源码 项目:Taurauto-Sharer 作者: sameerkumar18 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def auth(self,uname,passd):
        time.sleep(2)
        username = self.driver.find_element_by_id('email')
        password = self.driver.find_element_by_id('pass')
        username.send_keys(uname)
        password.send_keys(passd)
        password.send_keys(Keys.ENTER)
AutoShareFacebook.py 文件源码 项目:Taurauto-Sharer 作者: sameerkumar18 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def auth(self,uname,passd):
        time.sleep(2)
        username = self.driver.find_element_by_id('email')
        password = self.driver.find_element_by_id('pass')
        username.send_keys(uname)
        password.send_keys(passd)
        password.send_keys(Keys.ENTER)
AutoShareFacebook.py 文件源码 项目:Taurauto-Sharer 作者: sameerkumar18 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def auth(self,uname,passd):
        time.sleep(2)
        username = self.driver.find_element_by_id('email')
        password = self.driver.find_element_by_id('pass')
        username.send_keys(uname)
        password.send_keys(passd)
        password.send_keys(Keys.ENTER)
facebook.py 文件源码 项目:facebook-automation 作者: sjsafranek 项目源码 文件源码 阅读 70 收藏 0 点赞 0 评论 0
def _slow_type(self,word,elem):
        """ Mimics a human user typing """
        typing_speed = 42 #50 #wpm
        for letter in word:
            elem.send_keys(letter)
            time.sleep(random.random()*10.0/typing_speed)
        elem.send_keys(Keys.ENTER)


问题


面经


文章

微信
公众号

扫码关注公众号