<html>
<head>
<title></title>
</head>
<body>
<span class="bg s_ipt_wr quickdelete-wrap">
<input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
<a href="javascript:;" id="quickdelete" title="清空" class="quickdelete" style="top: 0px; right: 0px; display: none;" name="quickdelete"></a>
<span class="soutu-hover-tip" style="display: none;">按图片搜索</span></span>
</body>
</html>
By定位
By定位是webdriver提供的另一套定位页面元素的写法,统一用findelement()方法调用,
定位时需要先导入:_from selenium.webdriver.common.by import By
By定位一共提供了8种定位方法,具体如下: find_element(定位类型, “定位值”)
find_element(By.ID, “kw”)
find_element(By.NAME, “wd”)
find_element(By.CLASS_NAME, “s_ipt”)
find_element(By.TAG_NSME, “input”)
find_element(By.LINK_TEXT,”更多”)
find_element(By.PARTTAL_LINK_TEXT, “hao”)
find_element(By.XPATH, “//input[@id=’kw’]”)
find_element(By.CSS_SELECTOR, “div>input#kw”)
_