我爱编程

selenium 操作下拉框

2017-12-18  本文已影响150人  小强很帅

selenium操作下拉框的两种方法:

第一种就是普通的select 形式的用 tag name 去定位

log_Type = Select(dr.find_element_by_tag_name('select')).select_by_index(26)

第二种是div形式的下拉框

#先定位到下拉框

m=dr.find_element_by_xpath('//*[@id="componentsCombo"]').click()

time.sleep(3)

#再点击下拉框下的选项

dr.find_element_by_xpath('//*[@id="ext-gen34"]/div[3]').click()

dr.find_element_by_xpath('//[@id="pvBody_PageTemplate_innerHolder_ObjDetails_PassContent_MultpleConnectButton"]').click()

如果生成不了测试报告,是因为编辑器默认执行篮框里的

上一篇 下一篇

猜你喜欢

热点阅读