本文整理汇总了Python中selenium.webdriver.support.expected_conditions.text_to_be_present_in_element_value函数的典型用法代码示例。如果您正苦于以下问题:Python text_to_be_present_in_element_value函数的具体用法?Python text_to_be_present_in_element_value怎么用?Python text_to_be_present_in_element_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了text_to_be_present_in_element_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testExpectedConditionTextToBePresentInElementValue
def testExpectedConditionTextToBePresentInElementValue(self, driver, pages):
pages.load('booleanAttributes.html')
with pytest.raises(TimeoutException):
WebDriverWait(driver, 1).until(EC.text_to_be_present_in_element_value((By.ID, 'inputRequired'), 'Expected'))
driver.execute_script("setTimeout(function(){document.getElementById('inputRequired').value = 'Example Expected text'}, 200)")
WebDriverWait(driver, 1).until(EC.text_to_be_present_in_element_value((By.ID, 'inputRequired'), 'Expected'))
assert 'Example Expected text' == driver.find_element_by_id('inputRequired').get_attribute('value')
开发者ID:zhjwpku,项目名称:selenium,代码行数:7,代码来源:webdriverwait_tests.py
示例2: wait_updates
def wait_updates():
self.wait.until_not(EC.text_to_be_present_in_element_value(
(By.CLASS_NAME, 'js-cart-size'), ''
))
self.wait.until_not(EC.text_to_be_present_in_element_value(
(By.CLASS_NAME, 'js-mobile-cart-price'), ''
))
开发者ID:fidals,项目名称:shopelectro,代码行数:7,代码来源:tests_selenium_mobile.py
示例3: businessinsider_fetch_links
def businessinsider_fetch_links(string,driver):
check_sum=0
links_fetched = []
try:
driver.get('http://www.businessinsider.com/?IR=C')
check_sum=1
WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[4]/div[1]/div/div[3]/div/ul[2]/div/li[3]/a[1]/i')))
except:
while check_sum==1:
try:
driver.get('http://www.businessinsider.com/?IR=C')
WebDriverWait(driver, 100).until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[4]/div[1]/div/div[3]/div/ul[2]/div/li[3]/a[1]/i')))
check_sum=0
except:
print "Network Error... Trying to Reconnect!!!"
time.sleep(5)
try:
driver.find_element_by_xpath('/html/body/div[4]/div[1]/div/div[3]/div/ul[2]/div/li[3]/a[1]/i').click()
except:
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[4]/div[1]/div/div[3]/div/ul[2]/div/li[3]/a[1]/i').click()
try:
driver.find_element_by_xpath('/html/body/div[4]/div[2]/div/form/input').send_keys('"'+string+'"',Keys.RETURN)
except:
driver.find_element_by_xpath('/html/body/div[4]/div[1]/div/div[3]/div/ul[2]/div/li[3]/a[1]/i').click()
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[4]/div[2]/div/form/input').send_keys('"'+string+'"',Keys.RETURN)
try:
WebDriverWait(driver,1000).until(EC.text_to_be_present_in_element_value((By.XPATH,'//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/h3')))
driver.find_element_by_xpath('//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/h3')
except:
time.sleep(10)
if driver.find_element_by_xpath('//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/h3').text.split()[-2].strip()=='no':
driver.quit()
return []
elif driver.find_element_by_xpath('//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/h3').text.split()[-2].strip().isalpha:
page=0
else:
page=int(driver.find_element_by_xpath('//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/h3').text.split()[-2].strip())/20
while page>=0:
elem=driver.find_elements_by_xpath('//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div/div[2]/h3/a')
date=driver.find_elements_by_class_name('river-post__date')
for i,j in zip(elem,date):
i=i.get_attribute('href')
j=int(j.text.split(',')[1].strip())
if j<=2008 and i not in links_fetched:
links_fetched.append(i)
if page>0:
try:
driver.find_element_by_xpath('//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/ul/li[2]/a').click()
WebDriverWait(driver,100).until(EC.text_to_be_present_in_element_value((By.XPATH,'//*[@id="main-content"]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/h3')))
except:
'''Do Nothing...'''
page-=1
driver.quit()
return links_fetched
开发者ID:ethan-hunt-007,项目名称:newsSitesCrawl,代码行数:56,代码来源:news_bot.py
示例4: testExpectedConditionTextToBePresentInElementValue
def testExpectedConditionTextToBePresentInElementValue(self):
self._loadPage('booleanAttributes')
try:
WebDriverWait(self.driver, 1).until(EC.text_to_be_present_in_element_value((By.ID, 'inputRequired'), 'Expected'))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException as e:
pass
self.driver.execute_script("setTimeout(function(){document.getElementById('inputRequired').value = 'Example Expected text'}, 200)")
WebDriverWait(self.driver, 1).until(EC.text_to_be_present_in_element_value((By.ID, 'inputRequired'), 'Expected'))
self.assertEqual('Example Expected text', self.driver.find_element_by_id('inputRequired').get_attribute('value'))
开发者ID:NextGenIntelligence,项目名称:selenium,代码行数:10,代码来源:webdriverwait_tests.py
示例5: wait_for_first_host_active
def wait_for_first_host_active(self, value):
xpath_loc = (
AmazonEc2Locators.Ec2Locators.STATUS_LABEL_PREFIX + "1" + AmazonEc2Locators.Ec2Locators.STATUS_LABEL_SUFFIX
)
print xpath_loc
element = self.driver.find_element(xpath_loc)
element = WebDriverWait(self.driver, 10).until(EC.text_to_be_present_in_element_value(element, value))
开发者ID:aruneli,项目名称:rancher-test,代码行数:7,代码来源:AmazonEc2.py
示例6: assert_element_text_value
def assert_element_text_value(self, how, what, text, message):
try:
return WebDriverWait(self.driver, 10).until(
EC.text_to_be_present_in_element_value((how, what), text)
)
except:
self.fail(message)
开发者ID:Eforcers,项目名称:python-gae-template,代码行数:7,代码来源:gui_test.py
示例7: is_text_present_in_element
def is_text_present_in_element(locator, text, timeOut=0):
'''
Checking if the given text is present in the specified element\n
'''
try: _wait(timeOut).until(EC.text_to_be_present_in_element_value(Element(locator)._get(), text))
except WebDriverException: return False
return True
开发者ID:maddyvn,项目名称:Robot-framework_Test,代码行数:7,代码来源:Selenium2Extend.py
示例8: testExpectedConditionTextToBePresentInElementValue
def testExpectedConditionTextToBePresentInElementValue(self):
self._loadPage('booleanAttributes')
try:
WebDriverWait(self.driver, 1).until(EC.text_to_be_present_in_element_value((By.ID, 'inputRequired'), 'Expected'))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException, e:
pass
开发者ID:AlexandraChiorean,项目名称:Selenium2,代码行数:7,代码来源:webdriverwait_tests.py
示例9: solve_captcha
async def solve_captcha(url, api, driver, timestamp):
driver.get(url)
WebDriverWait(driver, 86400).until(EC.text_to_be_present_in_element_value((By.NAME, "g-recaptcha-response"), ""))
driver.switch_to.frame(driver.find_element_by_xpath("//*/iframe[@title='recaptcha challenge']"))
token = driver.find_element_by_id("recaptcha-token").get_attribute("value")
request = api.create_request()
request.verify_challenge(token=token)
request.get_hatched_eggs()
request.get_inventory(last_timestamp_ms=timestamp)
request.check_awarded_badges()
request.get_buddy_walked()
request.check_challenge()
for attempt in range(-1, conf.MAX_RETRIES):
try:
response = await request.call()
return response['responses']['VERIFY_CHALLENGE']['success']
except (ex.HashServerException, ex.MalformedResponseException, ex.ServerBusyOrOfflineException) as e:
if attempt == conf.MAX_RETRIES - 1:
raise
else:
print('{}, trying again soon.'.format(e))
await sleep(4)
except ex.NianticThrottlingException:
if attempt == conf.MAX_RETRIES - 1:
raise
else:
print('Throttled, trying again in 11 seconds.')
await sleep(11)
except (KeyError, TypeError):
return False
开发者ID:UnownFinder,项目名称:Monocle,代码行数:31,代码来源:solve_captchas.py
示例10: test_submit_invalid_number
def test_submit_invalid_number(url):
"""
Example test using Selenium to submit an HTML form.
Assumption is that the result will display an error
if invalid input is submitted.
"""
driver = None
try:
driver = webdriver.Firefox()
wait = WebDriverWait(driver, 10)
driver.get(url)
input_field = driver.find_element_by_id('number')
button = driver.find_element_by_id('getFibNumber')
invalid_number = 'Hello world!'
input_field.send_keys(invalid_number)
button.click()
try:
wait.until(ec.text_to_be_present_in_element_value(
(By.ID,'number'),'Invalid number'))
except TimeoutException:
# Expected response not found, continue with assert
traceback.print_exc()
result = input_field.get_attribute('value')
assert result != invalid_number, 'No error message was displayed for invalid input'
except OSError as e:
#Firefox not installed, skip test
print "Skipping Selenium test, Firefox not installed/found"
finally:
if driver:
driver.quit()
开发者ID:mbertrand,项目名称:fibtest,代码行数:30,代码来源:test_dg_fib_fe.py
示例11: test_submit_valid_number
def test_submit_valid_number(url):
"""
Example test using Selenium to submit an HTML form.
This assumes Firefox is installed. Asserts will be
skipped if Firefox cannot be found.
"""
driver = None
try:
driver = webdriver.Firefox()
wait = WebDriverWait(driver, 10)
driver.get(url)
input_field = driver.find_element_by_id('number')
button = driver.find_element_by_id('getFibNumber')
input_field.send_keys('4')
button.click()
try:
wait.until(ec.text_to_be_present_in_element_value((By.ID,'number'),'3'))
except TimeoutException:
# Expected response not found, continue with assert
traceback.print_exc()
assert input_field.get_attribute('value') == '3'
except OSError as e:
#Firefox not installed, skip test
print "Skipping Selenium test, Firefox not installed/found"
finally:
if driver:
driver.quit()
开发者ID:mbertrand,项目名称:fibtest,代码行数:27,代码来源:test_dg_fib_fe.py
示例12: go_to_next_page
def go_to_next_page(driver,current_page):
next_button = driver.find_elements_by_id("MainContent_GridView1_ButtonNext")
if(len(next_button) == 0):
return 1
while True:
try:
next_button[0].click()
WebDriverWait(driver,100).until(
EC.text_to_be_present_in_element_value(
(By.ID,"MainContent_GridView1_PageCurrent"),`current_page+1`
)
)
break
except:
print("Took too long to go to the next page, going to click again")
return 0
开发者ID:patricksheehan,项目名称:Database-Drill,代码行数:16,代码来源:database_drill.py
示例13: get_stock_price
def get_stock_price(self, symbol):
symbol_input_xpath = "/html/body/form/table[3]/tbody/tr/td[1]/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/input"
refresh_xpath = "/html/body/form/table[3]/tbody/tr/td[1]/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/span/a"
price_xpath = "/html/body/form/table[3]/tbody/tr/td[1]/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr[4]/td[2]"
self.enter_stock_menu()
time.sleep(3)
self.select_menu_frame()
element = self.driver.find_element_by_xpath("/html/body/table[2]/tbody/tr[1]/td/a")
element.click()
time.sleep(3)
self.select_main_frame()
element = self.driver.find_element_by_xpath(symbol_input_xpath)
element.send_keys(symbol)
time.sleep(3)
element = self.driver.find_element_by_xpath(refresh_xpath)
element.click()
time.sleep(3)
# wait the price is not 0
WebDriverWait(self.driver, 10).until_not(
EC.text_to_be_present_in_element_value((By.XPATH, price_xpath), "0")
)
element = self.driver.find_element_by_xpath(price_xpath)
if element.text == "0":
self.logger.critical("Price is 0")
price = float(element.text)
return price
开发者ID:zhangyiant,项目名称:gtja_trade,代码行数:33,代码来源:Trade.py
示例14: check_if_text_present_in_element_value
def check_if_text_present_in_element_value(webdriver, locator, text, message='text not present in element value',
timeout=2):
try:
WebDriverWait(webdriver, timeout).until(
expected_conditions.text_to_be_present_in_element_value(locator, text), message)
return True
except TimeoutException:
return False
开发者ID:LeXuZZ,项目名称:localway_tests,代码行数:8,代码来源:webelement.py
示例15: step_impl
def step_impl(context):
button = context.browser.find_element_by_xpath('//*[@id="form_78ea690540a24bd8b9dcfbf99e999fea"]/div[1]/div[5]/input')
button.click()
try:
WebDriverWait(context.browser, 10).until(EC.text_to_be_present_in_element_value((By.ID, 'msg_78ea690540a24bd8b9dcfbf99e999fea'), 'Thank you sending us your information. We will get back to you with your Chai :)'))
except(Exception):
traceback.print_exc()
# context.browser.find_element_by_xpath('//*[@id="form_78ea690540a24bd8b9dcfbf99e999fea"]/div[1]/div[1]/input and @class="form-value form-value-invalid"')
开发者ID:dstanza,项目名称:practice_selenium,代码行数:9,代码来源:lets_talk_tea_form.py
示例16: test_tc1
def test_tc1(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_name("first_name").clear()
driver.find_element_by_name("first_name").send_keys("Goerge")
driver.find_element_by_name("last_name").clear()
driver.find_element_by_name("last_name").send_keys("Peng")
driver.find_element_by_css_selector("input[type=\"submit\"]").click()
element = WebDriverWait(driver, 10).until(
expected_conditions.text_to_be_present_in_element_value((By.CSS_SELECTOR, 'body'), 'First name')
)
开发者ID:george-peng-git,项目名称:example_node,代码行数:11,代码来源:tc2_wd.py
示例17: wait_for_form_item_to_contain
def wait_for_form_item_to_contain(self, item=None, text=None):
item = HitchSeleniumItem(item)
if item.is_id:
WebDriverWait(self.driver, self.wait_for_timeout).until(
EC.text_to_be_present_in_element_value((By.ID, item.html_id), text)
)
else:
full_xpath = """//*[{}][{}]""".format(
" and ".join([
"""contains(concat(' ', normalize-space(@class), ' '), ' {} ')""".format(
class_name
) for class_name in item.html_classes]
),
str(item.index + 1) if item.index >= 0 else "last()"
)
WebDriverWait(self.driver, self.wait_for_timeout).until(
EC.text_to_be_present_in_element_value(
(By.XPATH, full_xpath), text
)
)
开发者ID:hitchtest,项目名称:hitchselenium,代码行数:21,代码来源:step_library.py
示例18: is_text_in_value
def is_text_in_value(self, locator, value, timeout=10):
'''
判断元素的value值,没定位到元素返回false,定位到返回判断结果布尔值
result = driver.text_in_element(locator, text)
'''
try:
result = WebDriverWait(self.driver, timeout, 1).until(EC.text_to_be_present_in_element_value(locator, value))
except TimeoutException:
print "元素没定位到:"+str(locator)
return False
else:
return result
开发者ID:dittoyy,项目名称:Web,代码行数:12,代码来源:selenium_pack12.py
示例19: waitPlaytime
def waitPlaytime(wait_time):
try:
playtime = browser.find_element_by_id("playTimeShow")
play_time = playtime.get_attribute("value")
print(play_time)
time.sleep(1)
element = WebDriverWait(browser, wait_time).until_not(
EC.text_to_be_present_in_element_value((By.ID, "playTimeShow"), play_time)
)
if element:
print("Test passed")
except Exception as e:
print(e)
print("Test may be failed, please check if you are still online or not")
开发者ID:nomadyun,项目名称:StudyPython,代码行数:14,代码来源:KPI_UITest.py
示例20: create_ptt
def create_ptt(self, name=None):
"""Create a personaltimetable with the provided name when provided"""
self.find((
By.XPATH,
"//button[contains(@class,'add-button')]//i[contains(@class,'fa fa-plus')]"
)).click()
name_input = self.find((By.CLASS_NAME, 'timetable-name'))
WebDriverWait(self.driver, self.TIMEOUT) \
.until(EC.text_to_be_present_in_element_value(
(By.CLASS_NAME, 'timetable-name'),
'Untitled Schedule'
))
if name:
name_input.clear()
name_input.send_keys(name)
开发者ID:majidaziz,项目名称:semesterly,代码行数:15,代码来源:test_utils.py
注:本文中的selenium.webdriver.support.expected_conditions.text_to_be_present_in_element_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论