标签:华为 路径 find search css index 搜索框 com hold
路径:e:/pythonpro/liuyun/selenium/demo1.py
1、通过ID值:
搜索框:<input id="search-input" name="wd" type="text" placeholder="其实搜索很简单^_^ !" value="" autocomplete="off">
搜索按钮:<input id="ai-topsearch" class="submit am-btn" index="1" type="submit" value="搜索">
e1 = driver.find_element_by_id("search-input") e1.send_keys("华为")
2、通过name值:
<input id="search-input" name="wd" type="text" placeholder="其实搜索很简单^_^ !" value="" autocomplete="off">
e2 =driver.find_element_by_name("wd") e2.send_keys("华为")
3、通过xpath:
# e3 = driver.find_element_by_xpath(‘//*[@id="search-input"]‘) # e3.send_keys("华为")
4、通过css selector
e4 = driver.find_element_by_css_selector(‘#search-input‘) e4.send_keys("华为")
e5 = driver.find_element_by_link_text(‘登录‘) #查找文本为‘登录’的a标签 e5.click() #点击登录
e6 = driver.find_element_by_partial_link_text(‘录‘) e6.click()
e7 = driver.find_element_by_class_name(‘search-group‘) e7.send_keys("华为")
e8 =driver.find_element_by_tag_name(‘xxx‘) e8.send_keys()
标签:华为 路径 find search css index 搜索框 com hold
原文地址:https://www.cnblogs.com/minirabbit/p/12037623.html