51Testing软件测试论坛
标题:
selenium+python无法定位模糊搜索显示下拉选择的控件
[打印本页]
作者:
suxi
时间:
2016-11-2 15:30
标题:
selenium+python无法定位模糊搜索显示下拉选择的控件
模糊搜索下拉控件无法定位
作者:
joykao
时间:
2016-11-2 16:38
找前端去问
作者:
掉渣饼
时间:
2016-11-3 09:21
可以把你要定位的当前部分源码发出来看下吗,以及你写的脚本发出来看下
作者:
suxi
时间:
2016-11-7 14:23
掉渣饼 发表于 2016-11-3 09:21
可以把你要定位的当前部分源码发出来看下吗,以及你写的脚本发出来看下
源代码:
<form>
<div class="form-group">
<input type="text" yxb-evt="insertContact" placeholder="输入联系人名称" style="display: none;"><div class="bootstrap-tagsinput"><span class="twitter-typeahead" style="position: relative; display: inline-block; direction: ltr;"><input type="text" style="width: 16em !important; position: absolute; top: 0px; left: 0px; border-color: transparent; box-shadow: none; opacity: 1; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" class="tt-hint" readonly="" autocomplete="off" spellcheck="false" tabindex="-1"><input type="text" placeholder="输入联系人名称" style="width: 16em !important; position: relative; vertical-align: top; background-color: transparent;" class="tt-input" autocomplete="off" spellcheck="false" dir="auto" size="16"><pre aria-hidden="true" style="position: absolute; visibility: hidden; white-space: pre; font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", STHeiti, "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; word-spacing: 0px; letter-spacing: 0px; text-indent: 0px; text-rendering: auto; text-transform: none;">su</pre><span class="tt-dropdown-menu" style="position: absolute; top: 100%; left: 0px; z-index: 100; display: none; right: auto;"><div class="tt-dataset-1"></div></span></span></div>
</div>
<div class="form-group" id="favoriteContactList">
<p>常用联系人</p>
<div class="group-block" oid="576a827c0cf2d8c5d7ac569b" ykb-data="15816780201">1</div><div class="group-block" oid="57cd50c60cf2d4822843dad2" ykb-data="13122119298">2</div><div class="group-block" oid="57d27afa0cf2d7f7156367e0" ykb-data="15921392611">3</div><div class="group-block" oid="5800398b0cf258e173bce980" ykb-data="15116270234">4</div></div>
</form>
脚本:定位选择
#鼠标停留
#ActionChains(driver).move_to_element(m).perform()
#time.sleep(4)
#点击选择
#m=driver.find_element_by_xpath("//*[@id='content']/div[2]/div/div/div[1]/div/div/div[2]/form/div[1]/div/span/span/div")
#ActionChains(driver).move_to_element(m).perform()
#driver.find_element_by_xpath("//span[class='tt-dropdown-menu']/div").click()
#t=driver.find_element_by_class_name("data-name").
driver.find_element_by_xpath("//*[@id='content']/div[2]/div/div/div[1]/div/div/div[2]/form/div[1]/div/span/pre").click()
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2