本文整理匯總了Python中selenium.webdriver.common.keys.Keys.ALT屬性的典型用法代碼示例。如果您正苦於以下問題:Python Keys.ALT屬性的具體用法?Python Keys.ALT怎麽用?Python Keys.ALT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類selenium.webdriver.common.keys.Keys
的用法示例。
在下文中一共展示了Keys.ALT屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start_captcha
# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ALT [as 別名]
def start_captcha():
driver = webdriver.Firefox()
driver.get("http://reddit.com")
driver.find_element(By.XPATH, "//*[@id=\"header-bottom-right\"]/span[1]/a").click()
time.sleep(1)
driver.find_element(By.ID, "user_reg").send_keys("qwertyuiop091231")
driver.find_element(By.ID, "passwd_reg").send_keys("THISISMYPASSWORD!!$")
driver.find_element(By.ID, "passwd2_reg").send_keys("THISISMYPASSWORD!!$")
driver.find_element(By.ID, "email_reg").send_keys("biggie.smalls123@gmail.com")
#driver.find_element_by_tag_name("body").send_keys(Keys.COMMAND + Keys.ALT + 'k')
iframeSwitch = driver.find_element(By.XPATH, "//*[@id=\"register-form\"]/div[6]/div/div/div/iframe")
driver.switch_to.frame(iframeSwitch)
driver.find_element(By.ID, "recaptcha-anchor").click()
# download captcha image
#
# split payload
#
# reverse_search
#
# driver.quit()
# determines if an image keywords matches the target keyword
# uses the synonyms of the image keyword
示例2: enablePlayerDiagnostics
# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ALT [as 別名]
def enablePlayerDiagnostics(self):
actions = ActionChains(self.driver)
actions.key_down(Keys.CONTROL).key_down(Keys.ALT).key_down(Keys.SHIFT).send_keys('d').perform()
示例3: switch_tab
# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ALT [as 別名]
def switch_tab(self, browser_instance=None, tab_number=None, browser_type="firefox"):
"""Switching to different tabs in a browser with unique tab_number"""
status = True
if browser_instance is None:
browser_instance = self.current_browser
if tab_number is not None:
try:
tab_number = int(tab_number)
except:
print_error("{0} is not a valid tab number".format(tab_number))
status = False
else:
if tab_number > len(browser_instance.window_handles) or tab_number < 1:
print_error("{0} is not a valid tab number".format(tab_number))
status = False
else:
tab_number -= 1
current_tab = 0
current_window_handle = browser_instance.current_window_handle
for i in range(0, len(browser_instance.window_handles)):
if browser_instance.window_handles[i] == current_window_handle:
current_tab = i
break
if tab_number != current_tab:
if current_tab < tab_number:
times = tab_number - current_tab
else:
times = len(browser_instance.window_handles) - current_tab
times += tab_number
if browser_type == "firefox":
action_chains = ActionChains(browser_instance)
action_chains.key_down(Keys.ALT)
for i in range(0, times):
action_chains.send_keys('`')
action_chains.perform()
else:
element = browser_instance.find_element_by_tag_name('body')
for i in range(0, times):
element.send_keys(Keys.LEFT_CONTROL, Keys.TAB)
browser_instance.switch_to.window(browser_instance.window_handles[tab_number])
else:
current_tab = 0
current_window_handle = browser_instance.current_window_handle
for i in range(0, len(browser_instance.window_handles)):
if browser_instance.window_handles[i] == current_window_handle:
current_tab = i
tab_number = current_tab + 1
if tab_number >= len(browser_instance.window_handles):
tab_number = 0
if browser_type == "firefox":
browser_instance.find_element_by_tag_name('body').send_keys(Keys.LEFT_ALT, '`')
else:
browser_instance.find_element_by_tag_name('body').send_keys(Keys.LEFT_CONTROL, Keys.TAB)
browser_instance.switch_to.window(browser_instance.window_handles[tab_number])
return status
示例4: close_tab
# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ALT [as 別名]
def close_tab(self, browser_instance=None, tab_number=None, browser_type="firefox"):
"""Closing tabs in a browser with unique tab_number"""
if browser_instance is None:
browser_instance = self.current_browser
if len(browser_instance.window_handles) > 1:
prior_current_tab = False
current_window_handler = browser_instance.current_window_handle
for i in range(0, len(browser_instance.window_handles)):
if browser_instance.window_handles[i] == current_window_handler:
prior_current_tab = i
status = True
if tab_number is not None:
status = self.switch_tab(browser_instance, tab_number, browser_type)
if status:
tab_number = int(tab_number) - 1
browser_instance.find_element_by_tag_name('body').send_keys(Keys.LEFT_CONTROL, 'w')
sleep(2)
if tab_number == len(browser_instance.window_handles):
tab_number -= 1
browser_instance.switch_to.window(browser_instance.window_handles[tab_number])
if prior_current_tab == len(browser_instance.window_handles):
prior_current_tab -= 1
if prior_current_tab != tab_number:
if tab_number < prior_current_tab:
times = prior_current_tab - tab_number
else:
times = len(browser_instance.window_handles) - tab_number
times += prior_current_tab
if browser_type == "firefox":
action_chains = ActionChains(browser_instance)
action_chains.key_down(Keys.ALT)
for i in range(0, times):
action_chains.send_keys('`')
action_chains.perform()
else:
element = browser_instance.find_element_by_tag_name('body')
for i in range(0, times):
element.send_keys(Keys.LEFT_CONTROL, Keys.TAB)
browser_instance.switch_to.window(browser_instance.window_handles[prior_current_tab])
else:
if browser_type == "firefox":
print_info("The tab_number argument is None. Current window will be closed")
else:
print_info("The tab_number argument is None. Current tab will be closed")
browser_instance.find_element_by_tag_name('body').send_keys(Keys.LEFT_CONTROL, 'w')
if prior_current_tab == len(browser_instance.window_handles):
prior_current_tab = 0
browser_instance.switch_to.window(browser_instance.window_handles[prior_current_tab])
else:
status = self.close_browser(browser_instance)
return status