import time from selenium import webdriver driver = webdriver.Firefox() driver.get(‘http://www.baidu.com‘) time.sleep(5) driver.find_element(‘id‘,‘kw‘).send_keys(‘中国‘) driver.find_element(‘id‘,‘su‘).click() time.sleep(10) driver.quit()
使用find_element()定位方法(字符串中间是空格需注意)
by_id= "id" by_xpath = "xpath" by_link_text = "link text" by_partial_text = "partial link text" by_name = "name" by_tag_name = "tag name" by_class_name = "class name" by_css_selector = "css selector"
location = ‘id‘ argument = ‘password2‘ br.find_element(location, argument) # 等同于 br.find_element_by_id(‘password2‘)
原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12607890.html
时间: 2024-10-09 17:59:58