键值解释
send_keys(Keys.BACK_SPACE)删除键BackSpace
send_keys(Keys.SPACE)空格键Space
send_keys(Keys.TAB)制表键Tab
send_keys(Keys.ESPACE)回退键Esc
send_keys(Keys.ENTER)回车键Enter
send_keys(Keys.CONTROL,‘a’)全选Ctrl+A
send_keys(Keys.CONTROL,‘c’)复制CTRL+C
send_keys(Keys.CONTROL,‘x’)剪切CTRL+X
send_keys(Keys.CONTROL,‘v’)粘贴Ctrl+V
send_keys(Keys.F1)键盘F1
send_keys(Keys.F12)键盘F12
定位元素:
根据父节点定位子节点
“//*[text()=\”国家\”]/div/input/span”
根据子节点定位父节点
“//*[text()=\”上海\”]/../../span”
“//div[text()=\”上海\”]/parent::*/parent::span”
根据兄节点定位弟节点
“//*[text()=\”上海\”]/../span[3]”
“//*[text()=\”上海\”]/following-sibling::span[2]”
根据弟节点定位兄节点
“//*[text()=\”上海\”]/../span[0]”
“//*[text()=\”上海\”]/preceding-sibling::span”
//*[contains(text(),’版本’)]
//input[contains(@name,’na’)] 查找name属性中包含na关键字的页面元素
get_attribute(“value”)