本文整理汇总了Python中selenium.webdriver.support.wait.WebDriverWait.find_element_by_tag_name方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.find_element_by_tag_name方法的具体用法?Python WebDriverWait.find_element_by_tag_name怎么用?Python WebDriverWait.find_element_by_tag_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.wait.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.find_element_by_tag_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_tag_name [as 别名]
def search(self, query):
self.ensure_login()
self.driver.switch_to_default_content()
try:
nav_search = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.ID, 'nav-search'))
)
nav_search.click()
self.ensure_frame('suggest')
form = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.TAG_NAME, 'form'))
)
search_bar = form.find_element_by_tag_name('input')
search_bar.send_keys(query)
show_results = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[@class="results"]/descendant::a'))
)
show_results.click()
self.driver.switch_to_default_content()
wrapper = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, 'front'))
)
iframe = wrapper.find_element_by_tag_name('iframe')
self.driver.switch_to_frame(iframe)
songs = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.TAG_NAME, 'tbody'))
)
first_song = songs.find_element_by_tag_name('tr')
first_song.click()
first_song.send_keys(Keys.RETURN)
except:
print('Can\'t find element...')
print(traceback.format_exc())
示例2: Create_Position
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_tag_name [as 别名]
def Create_Position(self, parametr, name):
self.driver.find_element_by_id('single-button').click()
if parametr == 'Department':
self.driver.find_element_by_xpath('//workers//div[1]/div[1]/ul/li[1]/a').click()
form = WebDriverWait(self.driver, 3).until(
EC.presence_of_element_located((By.TAG_NAME, "department-action"))
)
form.find_element_by_tag_name('input').send_keys(name)
form.find_element_by_xpath('.//div[3]/div[1]/button').click()
elif parametr == 'Position':
self.driver.find_element_by_xpath('//workers//div[1]/div[1]/ul/li[2]/a').click()
form = WebDriverWait(self.driver, 3).until(
EC.presence_of_element_located((By.TAG_NAME, "role-action"))
)
form.find_element_by_tag_name('input').send_keys(name)
form.find_element_by_xpath('.//div[3]/div[1]/button').click()
elif parametr == 'Worker':
self.driver.find_element_by_xpath('//workers//div[1]/div[1]/ul/li[3]/a').click()
return name