标签:tab from ctr webdriver 导入 python ble end port
follow yoyo
一般定位到元素后要对它进行输入,点击,双击,清除内容等操作
还可能使用模拟键盘操作,如回车,Table键,ctrL+C,Ctrl+V等
# coding:utf-8
from selenium import webdriver
# 导入键盘模块
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.hordehome.com")
driver.implicitly_wait(10)
driver.find_element_by_id("search-button").click()
driver.find_element_by_id("search-term").clear()
driver.find_element_by_id("search-term").send_keys("python")
# driver.find_element_by_id("search-term").submit() # 此方法行不通
# 模拟ENTER操作回车按钮
driver.find_element_by_id("search-term").send_keys(Keys.ENTER)
# 经常用到的键盘操作事件
send_keys(Keys.Fn)
send_keys(Keys.CONTROL,‘c‘)
send_keys(Keys.CONTROL,‘v‘)
send_keys(Keys.CONTROL,‘a‘)
send_keys(Keys.CONTROL,‘x‘)
send_keys(Keys.TAB)
Selenium3+python3--定位到元素后如何操作元素
标签:tab from ctr webdriver 导入 python ble end port
原文地址:https://www.cnblogs.com/shanliguniang/p/10647828.html