本文整理汇总了Python中selenium.webdriver.support.wait.WebDriverWait.submit方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.submit方法的具体用法?Python WebDriverWait.submit怎么用?Python WebDriverWait.submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.wait.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.submit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deactivate_user
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import submit [as 别名]
def deactivate_user(self, userName=None):
#local locator
_locDisabledStatusAction = (By.XPATH, "//button[@class='disabled status-action' and @name='action-deactivate']")
#find the element associated with the given user
user = self.__find_user(userName)
if user is None:
print "the given user is not found.\n"
return False
else:
try:
statusSelectButton = WebDriverWait(self.selenium,self._TimeOut). \
until(lambda s: user.find_element(*self._locStatusSelectButton))
except Exceptions.TimeoutException:
print "the submit button was not found.\n"
#check the current status of the button
status = statusSelectButton.text
if status == 'active':
#the current status is active, so click the button for the deactivation
statusSelectButton.click()
try:
deactivateButton = WebDriverWait(self.selenium,self._TimeOut). \
until(lambda s: user.find_element(*_locDisabledStatusAction))
#deactivateButton.click()
deactivateButton.submit()
except Exceptions.TimeoutException:
print "the submit button was not found.\n"
else:
#the current status is inactive, so no further action is needed
print "the user is already inactive.\n"
return True
示例2: test_contact_key_creator
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import submit [as 别名]
def test_contact_key_creator(self):
self.logger.info('Starting test_contact_key_creator')
#setup the doc on gdrive first
file_name = 'ContactKeyTest1'
ss_key = gdoc_util.upload_file_to_gdrive('contact_key_test1.tsv', file_name)
driver = self.driver
gdoc_util.login_gdrive(driver)
driver.get('%s%s' % (self.base_url, '?ss=' + ss_key))
gc = gspread.login(settings.DEFAULT_GDRIVE_EMAIL, settings.DEFAULT_GDRIVE_PW)
my_worksheet = gc.open_by_key(ss_key).sheet1
e2_val = my_worksheet.acell('E2')
self.logger.info('e2_val: %s' % e2_val)
#reset the cell
my_worksheet.update_acell('E2', '')
e2_val = my_worksheet.acell('E2')
self.logger.info('e2_val reset to: %s' %e2_val)
#now run the command
#switch to input form frame
driver.switch_to.frame(0)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.LINK_TEXT, "Hiplead"))
).click()
id_worksheet_name_INPUT = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "id_worksheet_name"))
)
id_worksheet_name_INPUT.clear()
id_worksheet_name_INPUT.send_keys(file_name)
Select(driver.find_element_by_id("id_scrapers")).select_by_value('contactKeyCreator')
driver.find_element_by_id("id_email").send_keys(settings.DEFAULT_GDRIVE_EMAIL)
driver.find_element_by_id("id_password").send_keys(settings.DEFAULT_GDRIVE_PW)
#ok, now submit the form
id_worksheet_name_INPUT.submit()
#then wait for task to complete
#this success alert only becomes visible when task is actually finished.
success_div = driver.find_element_by_class_name('time_remaining')
try:
WebDriverWait(driver, 10).until(
EC.visibility_of(success_div)
)
except StaleElementReferenceException as e:
#TODO The javascript DOM manipulation that results in StaleElementReferenceException needs to be resolved.
success_div = driver.find_element_by_class_name('time_remaining')
WebDriverWait(driver, 10).until(
EC.visibility_of(success_div)
)
#now validate cell value, since we know task has completed.
e2_val = my_worksheet.acell('E2')
self.logger.info('e2_val after test: %s' %e2_val)
self.assertEquals('john_franklin_smith_somedomain.net', e2_val.value)
self.logger.info( 'Finished test_contact_key_creator')