1.打开浏览器
browser=webdriver.Firefox()

2.打开页面
browser.get('http://www.baidu.com') //打开一个网页
browser.title/current_url/页面元素是否存在 //判断打开的页面是否正确

3.定位元素及操作
1.ele=browser.find_element_by_name() / browser.find_element_by_id() //定位元素

2.ele.clear() //清空输入框 ele.send_keys('输入内容') //输入内容
3.browser.back() //返回上一页

以上内容的实践总结


上图中使用到了元素定位的五种方法
fing_element_by_id()、find_element_by_name()、find_element_by_class_name()、find_elenment_by_link_text()、find_element_by_partial_link_text(0
上图中使用到了操作元素的三种方法
clear()、send_keys()、click()
其它几种获取页面元素的方法

元素操作方法

网友评论