当前位置: 首页>>代码示例>>Python>>正文


Python WebDriverWait.send_keys方法代码示例

本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.send_keys方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.send_keys方法的具体用法?Python WebDriverWait.send_keys怎么用?Python WebDriverWait.send_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.ui.WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.send_keys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
    def setUp(self):     
        self.url = ROOT + '/default/user/login'        
        get_browser=self.browser.get(self.url)
        time.sleep(2)

        # username = self.browser.find_element_by_name("username")
        # username = WebDriverWait(self, 10).until(lambda self : self.browser.find_element_by_name("username"))
        # username.send_keys(USERS['USER2'])

        mailstring = USERS['USER2']+'@user.com'
        email = self.browser.find_element_by_name("email")

        email = WebDriverWait(self, 10).until(lambda self: self.browser.find_element_by_name("email"))
        email.send_keys(mailstring)

        password = self.browser.find_element_by_name("password")    
        password.send_keys(USERS['PASSWORD2'])    

        submit_button = self.browser.find_element_by_css_selector("#submit_record__row input")
        submit_button.click()
        time.sleep(1)  
        
        self.url = ROOT + '/submit/new_question'        
        get_browser=self.browser.get(self.url)
        time.sleep(1)
开发者ID:DonaldMc,项目名称:gdms,代码行数:27,代码来源:test_p2addquestion.py

示例2: login

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
def login(driver):
    print('Logging in into %s ...' % EDIT_URL)
    driver.get(EDIT_URL)
    print('...')

    elem = WebDriverWait(driver, 30).until(
        EC.visibility_of_element_located((By.NAME, 'Email'))
    )
    elem.send_keys(LOGIN)
    try:
        # two-field login
        elem = driver.find_element_by_name('Passwd')
        elem.send_keys(PASS)
    except NoSuchElementException:
        # single-field login
        elem.send_keys(Keys.ENTER)
        elem = WebDriverWait(driver, 30).until(
            EC.visibility_of_element_located((By.NAME, 'Passwd'))
        )
        elem.send_keys(PASS)

    elem.send_keys(Keys.ENTER)
    print('Submitting ...')

    WebDriverWait(driver, 30).until(lambda x: x.title[-len(EDIT_TITLE):] == EDIT_TITLE)
    print('...')
开发者ID:SparKot,项目名称:foxtrick,代码行数:28,代码来源:cws_upload.py

示例3: select_button

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
 def select_button(self, key):
     '''
     运费策略
     '''
     driver = self.conf.driver
     driver.implicitly_wait(10)
     xpath = LC.COMMON[key]
     value = ["0", "1", "2", "3"]
     value0 = random.choice(value)
     number = random.randint(50, 200)
     time.sleep(1)
     ele = Select(driver.find_element_by_xpath(xpath=xpath))
     ele.select_by_value(value0)
     time.sleep(1)
     if value0 == "2":
         # 输入订单的满减金额
         xpath1 = '//*[@id="rule"]/form/div[6]/div/input'
         ele1 = WebDriverWait(driver, 20).until(lambda x: x.find_element_by_xpath(xpath=xpath1))
         time.sleep(1)
         ele1.send_keys(number)
         time.sleep(1)
     elif value0 == "3":
         # 输入订单的满减金额
         xpath2 = '//*[@id="rule"]/form/div[7]/div/input'
         ele1 = WebDriverWait(driver, 20).until(lambda x: x.find_element_by_xpath(xpath=xpath2))
         time.sleep(1)
         ele1.send_keys(number)
         time.sleep(0.5)
     else:
         time.sleep(0.5)
开发者ID:hyteer,项目名称:work,代码行数:32,代码来源:common.py

示例4: post_submission_thread_update

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
  def post_submission_thread_update(self, post_text):
    """
    Add Docstring
    """
    #self.login_to_page()
    
    content = urllib2.urlopen(self.submission_thread_url).read()
    soup = BeautifulSoup(content)
    page_links = soup.find('ul', 'b-pagination-list').findAll('a', 'b-pagination-item')
    final_page_number = int(page_links[-1].contents[0])
    final_thread_page_url = '{0}?page={1}'.format(self.submission_thread_url, str(final_page_number))
    print final_thread_page_url
    
    driver = webdriver.Firefox()
    driver.get(self.submission_thread_url)
    
    
    
    login_link = driver.find_element_by_link_text("Login")
    login_link.click()

    #Wait for availability of username field, then enter username, password, and click the login button
    login_name = WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.ID, "field-username")))
    login_name.send_keys(self.username)
    login_password = driver.find_element_by_id("field-loginFormPassword")
    login_password.send_keys(self.password)
    login_button = driver.find_element_by_name("login")
    login_button.click()
    
    driver.get(final_thread_page_url)
    
    text_area = WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.ID, "field-body")))
    text_area.send_keys(post_text)
开发者ID:oppecker,项目名称:PRC_Script,代码行数:35,代码来源:PRC_Forum_Tools.py

示例5: get_browser

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
def get_browser(username, password):
    """Get an instance of a firefox browser"""

    browser = webdriver.Firefox()
    browser.set_window_size(1020, 800)

    # set username
    browser.get('https://www.cgd.pt')
    elem = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.ID, 'input_cx1'))
    )
    elem.send_keys(username + Keys.ENTER)

    # close warnings
    elem = WebDriverWait(browser, 10).until(
        EC.element_to_be_clickable((By.XPATH, '//*[@title="Fechar Aviso"]'))
    )
    elem.click()

    # add password
    elem = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.ID, 'passwordInput'))
    )
    elem.send_keys(password + Keys.ENTER)

    # close warnings
    elem = WebDriverWait(browser, 10).until(
        EC.element_to_be_clickable((By.CLASS_NAME, 'botao_ok'))
    )
    elem.click()

    return browser
开发者ID:lmagomes,项目名称:misc,代码行数:34,代码来源:cgdcheck.py

示例6: test_create_new_draft_meeting

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
    def test_create_new_draft_meeting(self):
        self.login(self.u1)
        url = self.full_url(self.community.get_absolute_url())
        self.selenium.get(url)
        self.selenium.find_element_by_xpath('//a[@href="{}main/"]'.format(
            self.community.get_absolute_url())
        ).click()

        self.selenium.find_element_by_xpath('//a[@href="{}main/upcoming/edit/"]'.format(
            self.community.get_absolute_url())).click()

        title = WebDriverWait(self.selenium, 10).until(
            ec.presence_of_element_located((By.ID, "id_upcoming_meeting_title"))
        )
        title.send_keys("Meeting Title")
        self.selenium.find_element_by_id("id_upcoming_meeting_location").send_keys("Tel Aviv")
        self.selenium.find_element_by_id("id_upcoming_meeting_scheduled_at_0").send_keys("01/01/2017")
        self.selenium.find_element_by_id("id_upcoming_meeting_scheduled_at_1").send_keys("02:00PM", Keys.TAB)
        current_element = self.selenium.switch_to.active_element
        current_element.send_keys("Background...")
        self.selenium.find_element_by_xpath('//input[@type="submit"]').click()

        # Test: If there is a h1 title "Meeting Title", Its OK.
        time.sleep(0.6)
        self.assertTrue(self.is_element_present(By.XPATH, "//* [contains(text(), 'Meeting Title')]"))
开发者ID:Mengo33,项目名称:OpenCommunity,代码行数:27,代码来源:example_live_test.py

示例7: signup_with_short_password

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
	def signup_with_short_password(self):
		dname = WebDriverWait(self.webdriver, 10).until(EC.visibility_of_element_located((By.NAME, "form-display-name")), 'Timed Out')
		dname.send_keys("Test Person")
		self.webdriver.find_element_by_id("form-email2").send_keys("[email protected]")
		self.webdriver.find_element_by_id("form-password2").send_keys("12345")
		self.webdriver.find_element_by_id("confirm-form-password").send_keys("12345")
		return not self.webdriver.find_element_by_id("signup-btn").is_enabled()
开发者ID:judyyang40,项目名称:emFitting_automatedTesting,代码行数:9,代码来源:signin_page.py

示例8: test

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
def test():
    wd = webdriver.Firefox()
    wd.get('http://google.com')
    try:
        element = WebDriverWait(wd, 10).until(EC.presence_of_element_located((By.NAME, "q")))
    except Exception as e:
        print(e)
    finally:
        element.send_keys('hotel' + Keys.ENTER)

    wd.implicitly_wait(1)

    results = wd.find_elements_by_css_selector('li.g')
    parsed = []
    for result in results:
        link = title = snippet = ''
        try:
            link_element = result.find_element_by_css_selector('h3.r > a:first-child')
            link = link_element.get_attribute('href')
            title = link_element.text
        except Exception as e:
            print('link element couldnt be parsed')
        try:
            snippet = result.find_element_by_css_selector('div.s > span.st').text
        except Exception as e:
            print('snippet element couldnt be parsed')

        parsed.append((link, title, snippet))

    pprint.pprint(parsed)

    wd.close()
开发者ID:adammendoza,项目名称:GoogleScraper,代码行数:34,代码来源:sel_google.py

示例9: when_i_configure_valo_url

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
def when_i_configure_valo_url(step):

    valo_url = WebDriverWait(world.driver, 5).until(
            EC.presence_of_element_located((By.CSS_SELECTOR, '[data-type=valoLocation]') )
    )
    valo_url.clear()
    valo_url.send_keys(world.valo_url)
开发者ID:manuelvelez,项目名称:preliminary-testing,代码行数:9,代码来源:steps.py

示例10: fill_in_details

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
  def fill_in_details(self,driver,notes,fit_file):
    WebDriverWait(driver,5)
    driver.back()
    edit_link = driver.find_elements_by_class_name("Button")[0]
    edit_link.click()

    ## Wait for the "Upload" Button to be active, then click it.
    weight_box = WebDriverWait(driver, 10).until(
            lambda driver : driver.find_element_by_name("ctl00$ctl00$ctl00$SiteContent$PageContent$TrainingLogContent$Weight"))
    temperature_box = driver.find_element_by_name("ctl00$ctl00$ctl00$SiteContent$PageContent$TrainingLogContent$Temperature")
    notes_box = driver.find_element_by_name("ctl00$ctl00$ctl00$SiteContent$PageContent$TrainingLogContent$Notescta")
    save_button = driver.find_element_by_name("ctl00$ctl00$ctl00$SiteContent$PageContent$TrainingLogContent$Save")
    stars = driver.find_elements_by_class_name("Empty")

    weight = raw_input("Weight:")
    weight_box.send_keys(weight)
    
    weather = self.get_weather(fit_file)
    temperature = str(int(weather['temp_f']))
    temperature_box.send_keys(temperature)
    weather_summary = weather['weather_string']


    notes_box.send_keys( weather_summary + "\n")
    notes_box.send_keys(notes)
    quality = raw_input("Quality:1-10:")
    stars[int(quality)].click()
    effort = raw_input("Effort:1-10:")
    stars[int(effort)+10].click()
    save_button.click()
开发者ID:FreddieSanchez,项目名称:fit_uploader,代码行数:32,代码来源:fit_uploader.py

示例11: test_wp_login

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
    def test_wp_login(self):
        driver = self.driver
        wp_username = 'diegos17'
        wp_password = 'PASSWORD'

        # pobiera kazdy element ze strony za pomoca xpath - odpowiednio: pole email, password, przycisk zaloguj i
        # przycisk odbierz - bedziemy sprawdzac, czy wieswietla sie po zalogowaniu

        emailFieldXpath = "//input[@name='login_username']"
        passFieldXpath =  "//input[@name='login_password']"
        loginButtonXpath = "//input[@value='zaloguj']"
        odbierzButtonXpath = ".//*[@id='bxPanelTopBody']/div/div[1]/a[1]"

        # po wlaczeniu strony oczekuje sie wyswietlenia sie elementow, jesli nie wyswietla sie w 10 sekund - TimeOutExc.

        emailFieldElement   = WebDriverWait(driver,10).until(lambda driver: driver.find_element_by_xpath(emailFieldXpath))
        passFieldElement    = WebDriverWait(driver,10).until(lambda driver: driver.find_element_by_xpath(passFieldXpath))
        loginButtonElement  = WebDriverWait(driver,10).until(lambda driver: driver.find_element_by_xpath(loginButtonXpath))

        # czyszczenie pola email, wpisanie do niego danych
        emailFieldElement.clear()
        emailFieldElement.send_keys(wp_username)

        # czyszczenie pola password, wpisanie do niego danych
        passFieldElement.clear()
        passFieldElement.send_keys(wp_password)

        # klikniecie przycisku zaloguj
        loginButtonElement.click()

        #oczekiwanie na wyswietlenie sie danego elementu w celu sprawdzenia poprawnosci zalogowania
        WebDriverWait(driver,10).until(lambda driver: driver.find_element_by_xpath(odbierzButtonXpath))
开发者ID:BBBocian,项目名称:Python,代码行数:34,代码来源:wp_login.py

示例12: login_url

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
def login_url(timeout):
    #timeout=10
    driver=webdriver.Firefox()
    driver.get("https://support.industry.siemens.com/cs/signin?lc=zh-CN")
    time.sleep(3)

    print "******begin******"

    loginFrame=WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.ID,"frmLogin")))
    driver.switch_to_frame(loginFrame)


    username=WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.ID,"ContentPlaceHolder1_TextSiemensLogin")))
    username.send_keys(user)

    driver.find_element_by_id("ContentPlaceHolder1_TextPassword").send_keys(pwd)
    driver.find_element_by_id("ContentPlaceHolder1_LoginRememberUserNamePassword").click()
    driver.find_element_by_id("ContentPlaceHolder1_LoginUserNamePasswordButton").click()

    time.sleep(30)
    cookie = [item["name"] + "=" + item["value"] for item in driver.get_cookies()]

    driver.close()
    cookiestr = ';'.join(item for item in cookie)
    return cookiestr
开发者ID:ilovepp,项目名称:firminsight,代码行数:27,代码来源:siemensdownload.py

示例13: testWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
 def testWait(self):
     '''设置等待时间'''
     driver=self.driver
     driver.get(self.base_url)
     so=WebDriverWait(driver, 10).until(lambda  driver  :common.findID(driver,'kw'))
     so.send_keys('webdriver')
     time.sleep(3)
开发者ID:code2015wang,项目名称:python-selenium2,代码行数:9,代码来源:sina.py

示例14: test_MDT_open_new

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
    def test_MDT_open_new(self):
        WebDriverWait(self.driver, 5).until(EC.element_to_be_clickable((By.XPATH, self.helper.get_xpath("create_workspace_btn"))))

        workspace_name = "Open New MDT"
        return_msg = self.helper.open_new_workspace(workspace_name)
        self.assertEqual(return_msg, "OK", "Call to open_new_workspace failed: '" + return_msg + "'")

        #Verify the name of the workspace window that pops up
        self.driver.switch_to_window(self.driver.window_handles[-1])
        window_name = self.driver.title
        self.assertEqual(window_name, workspace_name, "Workspace window does not match name of workspace")

        #Make sure the user has a valid connection
        return_msg = self.helper.is_valid_connection()
        self.assertEqual(return_msg, "Connected", "Call to is_valid_connection failed: '" + return_msg + "'")

        #Enter product in search field
        element = WebDriverWait(self.driver, 5).until(EC.element_to_be_clickable((By.XPATH, self.helper.get_xpath("instrument_search"))))
        product = self.helper.get_product()
        element.send_keys(product)

        #Make sure the product entered in the search field matches each of the results returned
        what = self.helper.get_xpath("instrument_search_results")
        WebDriverWait(self.driver, 5).until(EC.presence_of_element_located((By.XPATH, what)))
        elements = self.driver.find_elements_by_xpath(what)
        for element in elements:
            self.assertIn(product, element.text, "Search string '" + product + "' not found in result '" + element.text + "'")

        #Click on the first search result and verify that MDT for that contract appears
        search_result_title = elements[0].text
        elements[0].click()
        what = self.helper.get_xpath("mdt_title")
        element = WebDriverWait(self.driver, 5).until(EC.presence_of_element_located((By.XPATH, what)))
        self.assertIn(search_result_title, element.text, "Search result instrument (" + search_result_title + ") was not found in title of MDT (" + element.text + ")")
开发者ID:joubertvisser,项目名称:jv,代码行数:36,代码来源:TC_Market_Depth_Trader.py

示例15: addReport

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import send_keys [as 别名]
 def addReport(self,content):
     #com.hecom.sales:id/workdaily_content
     contentEdit = WebDriverWait(self._driver, 10).until(EC.presence_of_element_located((By.ID, 'com.hecom.sales:id/workdaily_content')))
     contentEdit.send_keys(content)
     #self._driver.set_value(reasonEdit,reason)
     self._driver.keyevent(66)  #enter
     self._driver.hide_keyboard()
开发者ID:hecompanzhipiao,项目名称:HecomAuto,代码行数:9,代码来源:dailyReportPages.py


注:本文中的selenium.webdriver.support.ui.WebDriverWait.send_keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。